From d318611dd6f23fcfedd50e9b9e24620b102ba96a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 21:44:05 +0200 Subject: Adding upstream version 1.23.0. Signed-off-by: Daniel Baumann --- src/include/DviChar.h | 55 ++ src/include/XFontName.h | 50 ++ src/include/cmap.h | 55 ++ src/include/color.h | 88 +++ src/include/config.hin | 1584 ++++++++++++++++++++++++++++++++++++++++++++ src/include/cset.h | 74 +++ src/include/curtime.h | 27 + src/include/device.h | 25 + src/include/driver.h | 38 ++ src/include/errarg.h | 46 ++ src/include/error.h | 69 ++ src/include/font.h | 343 ++++++++++ src/include/geometry.h | 26 + src/include/getopt.h | 226 +++++++ src/include/getopt_int.h | 130 ++++ src/include/gettext.h | 22 + src/include/html-strings.h | 26 + src/include/htmlhint.h | 36 + src/include/include.am | 47 ++ src/include/index.h | 41 ++ src/include/itable.h | 193 ++++++ src/include/lf.h | 21 + src/include/lib.h | 161 +++++ src/include/localcharset.h | 40 ++ src/include/macropath.h | 22 + src/include/nonposix.h | 230 +++++++ src/include/paper.h | 36 + src/include/posix.h | 66 ++ src/include/printer.h | 97 +++ src/include/ptable.h | 233 +++++++ src/include/refid.h | 34 + src/include/relocate.h | 37 ++ src/include/search.h | 100 +++ src/include/searchpath.h | 30 + src/include/stringclass.h | 194 ++++++ src/include/symbol.h | 88 +++ src/include/unicode.h | 63 ++ 37 files changed, 4653 insertions(+) create mode 100644 src/include/DviChar.h create mode 100644 src/include/XFontName.h create mode 100644 src/include/cmap.h create mode 100644 src/include/color.h create mode 100644 src/include/config.hin create mode 100644 src/include/cset.h create mode 100644 src/include/curtime.h create mode 100644 src/include/device.h create mode 100644 src/include/driver.h create mode 100644 src/include/errarg.h create mode 100644 src/include/error.h create mode 100644 src/include/font.h create mode 100644 src/include/geometry.h create mode 100644 src/include/getopt.h create mode 100644 src/include/getopt_int.h create mode 100644 src/include/gettext.h create mode 100644 src/include/html-strings.h create mode 100644 src/include/htmlhint.h create mode 100644 src/include/include.am create mode 100644 src/include/index.h create mode 100644 src/include/itable.h create mode 100644 src/include/lf.h create mode 100644 src/include/lib.h create mode 100644 src/include/localcharset.h create mode 100644 src/include/macropath.h create mode 100644 src/include/nonposix.h create mode 100644 src/include/paper.h create mode 100644 src/include/posix.h create mode 100644 src/include/printer.h create mode 100644 src/include/ptable.h create mode 100644 src/include/refid.h create mode 100644 src/include/relocate.h create mode 100644 src/include/search.h create mode 100644 src/include/searchpath.h create mode 100644 src/include/stringclass.h create mode 100644 src/include/symbol.h create mode 100644 src/include/unicode.h (limited to 'src/include') diff --git a/src/include/DviChar.h b/src/include/DviChar.h new file mode 100644 index 0000000..1100d81 --- /dev/null +++ b/src/include/DviChar.h @@ -0,0 +1,55 @@ +/* -*- C -*- */ +/* Copyright (C) 2014-2020 Free Software Foundation, Inc. + +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 of the License, 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 can find the license text at +. */ + +/* + * DviChar.h + * + * descriptions for mapping dvi names to + * font indexes and back. Dvi fonts are all + * 256 elements (actually only 256-32 are usable). + * + * The encoding names are taken from X - + * case insensitive, a dash separating the + * CharSetRegistry from the CharSetEncoding + */ + +# define DVI_MAX_SYNONYMS 10 +# define DVI_MAP_SIZE 256 +# define DVI_HASH_SIZE 256 + +typedef struct _dviCharNameHash { + struct _dviCharNameHash *next; + const char *name; + int position; +} DviCharNameHash; + +typedef struct _dviCharNameMap { + const char *encoding; + int special; + const char *dvi_names[DVI_MAP_SIZE][DVI_MAX_SYNONYMS]; + DviCharNameHash *buckets[DVI_HASH_SIZE]; +} DviCharNameMap; + +DviCharNameMap *DviFindMap (char *); +void DviRegisterMap (DviCharNameMap *); +#ifdef NOTDEF +char *DviCharName (DviCharNameMap *, int, int); +#else +#define DviCharName(map,index,synonym) ((map)->dvi_names[index][synonym]) +#endif +int DviCharIndex (DviCharNameMap *, const char *); diff --git a/src/include/XFontName.h b/src/include/XFontName.h new file mode 100644 index 0000000..4e9c694 --- /dev/null +++ b/src/include/XFontName.h @@ -0,0 +1,50 @@ +typedef struct _xFontName { + char Registry[256]; + char Foundry[256]; + char FamilyName[256]; + char WeightName[256]; + char Slant[3]; + char SetwidthName[256]; + char AddStyleName[256]; + unsigned int PixelSize; + unsigned int PointSize; + unsigned int ResolutionX; + unsigned int ResolutionY; + char Spacing[2]; + unsigned int AverageWidth; + char CharSetRegistry[256]; + char CharSetEncoding[256]; +} XFontName; + +#define FontNameRegistry (1<<0) +#define FontNameFoundry (1<<1) +#define FontNameFamilyName (1<<2) +#define FontNameWeightName (1<<3) +#define FontNameSlant (1<<4) +#define FontNameSetwidthName (1<<5) +#define FontNameAddStyleName (1<<6) +#define FontNamePixelSize (1<<7) +#define FontNamePointSize (1<<8) +#define FontNameResolutionX (1<<9) +#define FontNameResolutionY (1<<10) +#define FontNameSpacing (1<<11) +#define FontNameAverageWidth (1<<12) +#define FontNameCharSetRegistry (1<<13) +#define FontNameCharSetEncoding (1<<14) + +#define SlantRoman "R" +#define SlantItalic "I" +#define SlantOblique "O" +#define SlantReverseItalic "RI" +#define SlantReverseOblique "RO" + +#define SpacingMonoSpaced "M" +#define SpacingProportional "P" +#define SpacingCharacterCell "C" + +typedef char *XFontNameString; + +Bool XParseFontName (XFontNameString, XFontName *, unsigned int *); +Bool XFormatFontName (XFontName *, unsigned int, XFontNameString); +Bool XCompareFontName (XFontName *, XFontName *, unsigned int); +Bool XCopyFontName (XFontName *, XFontName *, unsigned int); diff --git a/src/include/cmap.h b/src/include/cmap.h new file mode 100644 index 0000000..3a62da1 --- /dev/null +++ b/src/include/cmap.h @@ -0,0 +1,55 @@ +// -*- C++ -*- +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +#ifndef UCHAR_MAX +#define UCHAR_MAX 255 +#endif + +enum cmap_builtin { CMAP_BUILTIN }; + +class cmap { +public: + cmap(); + cmap(cmap_builtin); + int operator()(unsigned char) const; + unsigned char &operator[](unsigned char); + + friend class cmap_init; +private: + unsigned char v[UCHAR_MAX+1]; +}; + +inline int cmap::operator()(unsigned char c) const +{ + return v[c]; +} + +inline unsigned char &cmap::operator[](unsigned char c) +{ + return v[c]; +} + +extern cmap cmlower; +extern cmap cmupper; + +static class cmap_init { + static int initialised; +public: + cmap_init(); +} _cmap_init; diff --git a/src/include/color.h b/src/include/color.h new file mode 100644 index 0000000..e3f945b --- /dev/null +++ b/src/include/color.h @@ -0,0 +1,88 @@ +// -*- C++ -*- +/* /src/include/color.h +Copyright (C) 2001-2020 Free Software Foundation, Inc. + Written by Gaius Mulley + +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 3 of the License, 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 this program. If not, see . */ + +#include +#include "symbol.h" + +enum color_scheme {DEFAULT, CMY, CMYK, RGB, GRAY}; + +class color { +private: + color_scheme scheme; + unsigned int components[4]; + color *next; + + int read_encoding(const color_scheme, const char * const, + const size_t); + +public: + symbol nm; + enum {MAX_COLOR_VAL = 0xffff}; + color(symbol s = default_symbol) : scheme(DEFAULT), nm(s) {} + color(const color * const); + ~color(); + + int operator==(const color & c) const; + int operator!=(const color & c) const; + + int is_default() { return scheme == DEFAULT; } + + // set color from given color component values + void set_default(); + void set_rgb(const unsigned int r, const unsigned int g, + const unsigned int b); + void set_cmy(const unsigned int c, const unsigned int m, + const unsigned int y); + void set_cmyk(const unsigned int c, const unsigned int m, + const unsigned int y, const unsigned int k); + void set_gray(const unsigned int g); + + // set color from a color string + int read_rgb(const char * const s); + int read_cmy(const char * const s); + int read_cmyk(const char * const s); + int read_gray(const char * const s); + + // Return the actual color scheme and retrieve the color components + // into a predefined vector (of length at least 4). + color_scheme get_components(unsigned int *c) const; + + // retrieve the components of a color + void get_rgb(unsigned int *r, unsigned int *g, unsigned int *b) const; + void get_cmy(unsigned int *c, unsigned int *m, unsigned int *y) const; + void get_cmyk(unsigned int *c, unsigned int *m, + unsigned int *y, unsigned int *k) const; + void get_gray(unsigned int *g) const; + + char *print_color(); +}; + +#define Cyan components[0] +#define Magenta components[1] +#define Yellow components[2] +#define Black components[3] + +#define Red components[0] +#define Green components[1] +#define Blue components[2] + +#define Gray components[0] + +extern color default_color; diff --git a/src/include/config.hin b/src/include/config.hin new file mode 100644 index 0000000..374b4c6 --- /dev/null +++ b/src/include/config.hin @@ -0,0 +1,1584 @@ +/* src/include/config.hin. Generated from configure.ac by autoheader. */ + +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD + +/* Define to the number of bits in type 'ptrdiff_t'. */ +#undef BITSIZEOF_PTRDIFF_T + +/* Define to the number of bits in type 'sig_atomic_t'. */ +#undef BITSIZEOF_SIG_ATOMIC_T + +/* Define to the number of bits in type 'size_t'. */ +#undef BITSIZEOF_SIZE_T + +/* Define to the number of bits in type 'wchar_t'. */ +#undef BITSIZEOF_WCHAR_T + +/* Define to the number of bits in type 'wint_t'. */ +#undef BITSIZEOF_WINT_T + +/* Define if you wish *printf() functions that have a safe handling of + non-IEEE-754 'long double' values. */ +#undef CHECK_PRINTF_SAFE + +/* Define to 1 if using 'alloca.c'. */ +#undef C_ALLOCA + +/* Define as the bit index in the word where to find bit 0 of the exponent of + 'double'. */ +#undef DBL_EXPBIT0_BIT + +/* Define as the word index where to find the exponent of 'double'. */ +#undef DBL_EXPBIT0_WORD + +/* Define as the bit index in the word where to find the sign of 'double'. */ +#undef DBL_SIGNBIT_BIT + +/* Define as the word index where to find the sign of 'double'. */ +#undef DBL_SIGNBIT_WORD + +/* Define as the bit index in the word where to find bit 0 of the exponent of + 'float'. */ +#undef FLT_EXPBIT0_BIT + +/* Define as the word index where to find the exponent of 'float'. */ +#undef FLT_EXPBIT0_WORD + +/* Define as the bit index in the word where to find the sign of 'float'. */ +#undef FLT_SIGNBIT_BIT + +/* Define as the word index where to find the sign of 'float'. */ +#undef FLT_SIGNBIT_WORD + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module fscanf shall be considered present. */ +#undef GNULIB_FSCANF + +/* Define to 1 if printf and friends should be labeled with attribute + "__gnu_printf__" instead of "__printf__" */ +#undef GNULIB_PRINTF_ATTRIBUTE_FLAVOR_GNU + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module scanf shall be considered present. */ +#undef GNULIB_SCANF + +/* Define to a C preprocessor expression that evaluates to 1 or 0, depending + whether the gnulib module snprintf shall be considered present. */ +#undef GNULIB_SNPRINTF + +/* Define to 1 when the gnulib module fgetc should be tested. */ +#undef GNULIB_TEST_FGETC + +/* Define to 1 when the gnulib module fgets should be tested. */ +#undef GNULIB_TEST_FGETS + +/* Define to 1 when the gnulib module fprintf should be tested. */ +#undef GNULIB_TEST_FPRINTF + +/* Define to 1 when the gnulib module fprintf-posix should be tested. */ +#undef GNULIB_TEST_FPRINTF_POSIX + +/* Define to 1 when the gnulib module fputc should be tested. */ +#undef GNULIB_TEST_FPUTC + +/* Define to 1 when the gnulib module fputs should be tested. */ +#undef GNULIB_TEST_FPUTS + +/* Define to 1 when the gnulib module fread should be tested. */ +#undef GNULIB_TEST_FREAD + +/* Define to 1 when the gnulib module free-posix should be tested. */ +#undef GNULIB_TEST_FREE_POSIX + +/* Define to 1 when the gnulib module frexp should be tested. */ +#undef GNULIB_TEST_FREXP + +/* Define to 1 when the gnulib module frexpl should be tested. */ +#undef GNULIB_TEST_FREXPL + +/* Define to 1 when the gnulib module fscanf should be tested. */ +#undef GNULIB_TEST_FSCANF + +/* Define to 1 when the gnulib module fwrite should be tested. */ +#undef GNULIB_TEST_FWRITE + +/* Define to 1 when the gnulib module getc should be tested. */ +#undef GNULIB_TEST_GETC + +/* Define to 1 when the gnulib module getchar should be tested. */ +#undef GNULIB_TEST_GETCHAR + +/* Define to 1 when the gnulib module memchr should be tested. */ +#undef GNULIB_TEST_MEMCHR + +/* Define to 1 when the gnulib module printf should be tested. */ +#undef GNULIB_TEST_PRINTF + +/* Define to 1 when the gnulib module putc should be tested. */ +#undef GNULIB_TEST_PUTC + +/* Define to 1 when the gnulib module putchar should be tested. */ +#undef GNULIB_TEST_PUTCHAR + +/* Define to 1 when the gnulib module puts should be tested. */ +#undef GNULIB_TEST_PUTS + +/* Define to 1 when the gnulib module scanf should be tested. */ +#undef GNULIB_TEST_SCANF + +/* Define to 1 when the gnulib module signbit should be tested. */ +#undef GNULIB_TEST_SIGNBIT + +/* Define to 1 when the gnulib module snprintf should be tested. */ +#undef GNULIB_TEST_SNPRINTF + +/* Define to 1 when the gnulib module vfprintf should be tested. */ +#undef GNULIB_TEST_VFPRINTF + +/* Define to 1 when the gnulib module vprintf should be tested. */ +#undef GNULIB_TEST_VPRINTF + +/* Define to 1 when the gnulib module vsnprintf should be tested. */ +#undef GNULIB_TEST_VSNPRINTF + +/* Define to 1 when the gnulib module wcwidth should be tested. */ +#undef GNULIB_TEST_WCWIDTH + +/* Define to 1 if you have 'alloca' after including , a header that + may be supplied by this distribution. */ +#undef HAVE_ALLOCA + +/* Define to 1 if works. */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_BP_SYM_H + +/* Define if you have a C++ . */ +#undef HAVE_CC_INTTYPES_H + +/* Define if you have a C++ . */ +#undef HAVE_CC_LIMITS_H + +/* Define if you have a C++ . */ +#undef HAVE_CC_OSFCN_H + +/* Define if the copysignf function is declared in and available in + libc. */ +#undef HAVE_COPYSIGNF_IN_LIBC + +/* Define if the copysignl function is declared in and available in + libc. */ +#undef HAVE_COPYSIGNL_IN_LIBC + +/* Define if the copysign function is declared in and available in + libc. */ +#undef HAVE_COPYSIGN_IN_LIBC + +/* Define to 1 if you have the header file. */ +#undef HAVE_CRTDEFS_H + +/* Define to 1 if the static_assert keyword works. */ +#undef HAVE_C_STATIC_ASSERT + +/* Define to 1 if you have the declaration of `alarm', and to 0 if you don't. + */ +#undef HAVE_DECL_ALARM + +/* Define to 1 if you have the declaration of `copysign', and to 0 if you + don't. */ +#undef HAVE_DECL_COPYSIGN + +/* Define to 1 if you have the declaration of `copysignf', and to 0 if you + don't. */ +#undef HAVE_DECL_COPYSIGNF + +/* Define to 1 if you have the declaration of `copysignl', and to 0 if you + don't. */ +#undef HAVE_DECL_COPYSIGNL + +/* Define to 1 if you have the declaration of `ecvt', and to 0 if you don't. + */ +#undef HAVE_DECL_ECVT + +/* Define to 1 if you have the declaration of `execvpe', and to 0 if you + don't. */ +#undef HAVE_DECL_EXECVPE + +/* Define to 1 if you have the declaration of `fcloseall', and to 0 if you + don't. */ +#undef HAVE_DECL_FCLOSEALL + +/* Define to 1 if you have the declaration of `fcvt', and to 0 if you don't. + */ +#undef HAVE_DECL_FCVT + +/* Define to 1 if you have the declaration of `gcvt', and to 0 if you don't. + */ +#undef HAVE_DECL_GCVT + +/* Define to 1 if you have the declaration of `getc_unlocked', and to 0 if you + don't. */ +#undef HAVE_DECL_GETC_UNLOCKED + +/* Define to 1 if you have the declaration of `getw', and to 0 if you don't. + */ +#undef HAVE_DECL_GETW + +/* Define to 1 if you have the declaration of `putw', and to 0 if you don't. + */ +#undef HAVE_DECL_PUTW + +/* Define to 1 if you have the declaration of `snprintf', and to 0 if you + don't. */ +#undef HAVE_DECL_SNPRINTF + +/* Define to 1 if you have the declaration of `strsignal', and to 0 if you + don't. */ +#undef HAVE_DECL_STRSIGNAL + +/* Define to 1 if you have the declaration of `sys_siglist', and to 0 if you + don't. */ +#undef HAVE_DECL_SYS_SIGLIST + +/* Define to 1 if you have the declaration of `towlower', and to 0 if you + don't. */ +#undef HAVE_DECL_TOWLOWER + +/* Define to 1 if you have the declaration of `vsnprintf', and to 0 if you + don't. */ +#undef HAVE_DECL_VSNPRINTF + +/* Define to 1 if you have the declaration of `wcsdup', and to 0 if you don't. + */ +#undef HAVE_DECL_WCSDUP + +/* Define to 1 if you have the declaration of `wcwidth', and to 0 if you + don't. */ +#undef HAVE_DECL_WCWIDTH + +/* Define to 1 if you have the declaration of `_snprintf', and to 0 if you + don't. */ +#undef HAVE_DECL__SNPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_DIRECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DIRENT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FEATURES_H + +/* Define to 1 if you have the `fmod' function. */ +#undef HAVE_FMOD + +/* Define if the 'free' function is guaranteed to preserve errno. */ +#undef HAVE_FREE_POSIX + +/* Define if the frexpl function is available in libc. */ +#undef HAVE_FREXPL_IN_LIBC + +/* Define if the frexp function is available in libc. */ +#undef HAVE_FREXP_IN_LIBC + +/* Define to 1 if you have the `getcwd' function. */ +#undef HAVE_GETCWD + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define if you have the iconv() function and it works. */ +#undef HAVE_ICONV + +/* Define if you have the 'intmax_t' type in or . */ +#undef HAVE_INTMAX_T + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define if exists, doesn't clash with , and + declares uintmax_t. */ +#undef HAVE_INTTYPES_H_WITH_UINTMAX + +/* Define to 1 if you have the `isatty' function. */ +#undef HAVE_ISATTY + +/* Define if the isnan(double) function is available in libc. */ +#undef HAVE_ISNAND_IN_LIBC + +/* Define if the isnan(float) function is available in libc. */ +#undef HAVE_ISNANF_IN_LIBC + +/* Define if the isnan(long double) function is available in libc. */ +#undef HAVE_ISNANL_IN_LIBC + +/* Define to 1 if you have the `iswcntrl' function. */ +#undef HAVE_ISWCNTRL + +/* Define to 1 if you have the `kill' function. */ +#undef HAVE_KILL + +/* Define if you have and nl_langinfo(CODESET). */ +#undef HAVE_LANGINFO_CODESET + +/* Define if the ldexpl function is available in libc. */ +#undef HAVE_LDEXPL_IN_LIBC + +/* Define if the ldexp function is available in libc. */ +#undef HAVE_LDEXP_IN_LIBC + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIMITS_H + +/* Define to 1 if the system has the type 'long long int'. */ +#undef HAVE_LONG_LONG_INT + +/* Define to 1 if mmap()'s MAP_ANONYMOUS flag is available after including + config.h and . */ +#undef HAVE_MAP_ANONYMOUS + +/* Define to 1 if you have the header file. */ +#undef HAVE_MATH_H + +/* Define to 1 if you have the `mbrtowc' function. */ +#undef HAVE_MBRTOWC + +/* Define to 1 if you have the header file. */ +#undef HAVE_MINIX_CONFIG_H + +/* Define if you have mkstemp(). */ +#undef HAVE_MKSTEMP + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the `mprotect' function. */ +#undef HAVE_MPROTECT + +/* Define to 1 if you have the `nl_langinfo' function. */ +#undef HAVE_NL_LANGINFO + +/* Define to 1 if you have the header file. */ +#undef HAVE_PROCESS_H + +/* Define to 1 if you have the `putenv' function. */ +#undef HAVE_PUTENV + +/* Define to 1 if you have the `rename' function. */ +#undef HAVE_RENAME + +/* Define to 1 if 'long double' and 'double' have the same representation. */ +#undef HAVE_SAME_LONG_DOUBLE_AS_DOUBLE + +/* Define to 1 if you have the `setlocale' function. */ +#undef HAVE_SETLOCALE + +/* Define to 1 if 'sig_atomic_t' is a signed integer type. */ +#undef HAVE_SIGNED_SIG_ATOMIC_T + +/* Define to 1 if 'wchar_t' is a signed integer type. */ +#undef HAVE_SIGNED_WCHAR_T + +/* Define to 1 if 'wint_t' is a signed integer type. */ +#undef HAVE_SIGNED_WINT_T + +/* Define to 1 if you have the `snprintf' function. */ +#undef HAVE_SNPRINTF + +/* Define if the return value of the snprintf function is the number of of + bytes (excluding the terminating NUL) that would have been produced if the + buffer had been large enough. */ +#undef HAVE_SNPRINTF_RETVAL_C99 + +/* Define if the string produced by the snprintf function is always NUL + terminated. */ +#undef HAVE_SNPRINTF_TRUNCATION_C99 + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDBOOL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDDEF_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define if exists, doesn't clash with , and declares + uintmax_t. */ +#undef HAVE_STDINT_H_WITH_UINTMAX + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strcasecmp' function. */ +#undef HAVE_STRCASECMP + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strncasecmp' function. */ +#undef HAVE_STRNCASECMP + +/* Define to 1 if you have the `strnlen' function. */ +#undef HAVE_STRNLEN + +/* Define to 1 if you have the `strsep' function. */ +#undef HAVE_STRSEP + +/* Define to 1 if you have the `strtol' function. */ +#undef HAVE_STRTOL + +/* Define if defines struct exception. */ +#undef HAVE_STRUCT_EXCEPTION + +/* Define to 1 if you have the `symlink' function. */ +#undef HAVE_SYMLINK + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_BITYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_DIR_H + +/* Define if you have sys_errlist in , , or . */ +#undef HAVE_SYS_ERRLIST + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define if you have sys_nerr in , , or . */ +#undef HAVE_SYS_NERR + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_PARAM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the `towlower' function. */ +#undef HAVE_TOWLOWER + +/* uchardet library availability */ +#undef HAVE_UCHARDET + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if the system has the type 'unsigned long long int'. */ +#undef HAVE_UNSIGNED_LONG_LONG_INT + +/* Define to 1 if you have the `vasnprintf' function. */ +#undef HAVE_VASNPRINTF + +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCHAR_H + +/* Define if you have the 'wchar_t' type. */ +#undef HAVE_WCHAR_T + +/* Define to 1 if you have the `wcrtomb' function. */ +#undef HAVE_WCRTOMB + +/* Define to 1 if you have the `wcslen' function. */ +#undef HAVE_WCSLEN + +/* Define to 1 if you have the `wcsnlen' function. */ +#undef HAVE_WCSNLEN + +/* Define to 1 if you have the header file. */ +#undef HAVE_WCTYPE_H + +/* Define to 1 if you have the `wcwidth' function. */ +#undef HAVE_WCWIDTH + +/* Define if you have the 'wint_t' type. */ +#undef HAVE_WINT_T + +/* Define to 1 if O_NOATIME works. */ +#undef HAVE_WORKING_O_NOATIME + +/* Define to 1 if O_NOFOLLOW works. */ +#undef HAVE_WORKING_O_NOFOLLOW + +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + +/* Define to 1 if you have the `__fseterr' function. */ +#undef HAVE___FSETERR + +/* Define to 1 if ctype.h defines __header_inline. */ +#undef HAVE___HEADER_INLINE + +/* Please see the Gnulib manual for how to use these macros. + + Suppress extern inline with HP-UX cc, as it appears to be broken; see + . + + Suppress extern inline with Sun C in standards-conformance mode, as it + mishandles inline functions that call each other. E.g., for 'inline void f + (void) { } inline void g (void) { f (); }', c99 incorrectly complains + 'reference to static identifier "f" in extern inline function'. + This bug was observed with Oracle Developer Studio 12.6 + (Sun C 5.15 SunOS_sparc 2017/05/30). + + Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) + on configurations that mistakenly use 'static inline' to implement + functions or macros in standard C headers like . For example, + if isdigit is mistakenly implemented via a static inline function, + a program containing an extern inline function that calls isdigit + may not work since the C standard prohibits extern inline functions + from calling static functions (ISO C 99 section 6.7.4.(3). + This bug is known to occur on: + + OS X 10.8 and earlier; see: + https://lists.gnu.org/r/bug-gnulib/2012-12/msg00023.html + + DragonFly; see + http://muscles.dragonflybsd.org/bulk/clang-master-potential/20141111_102002/logs/ah-tty-0.3.12.log + + FreeBSD; see: + https://lists.gnu.org/r/bug-gnulib/2014-07/msg00104.html + + OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and + for clang but remains for g++; see . + Assume DragonFly and FreeBSD will be similar. + + GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 + inline semantics, unless -fgnu89-inline is used. It defines a macro + __GNUC_STDC_INLINE__ to indicate this situation or a macro + __GNUC_GNU_INLINE__ to indicate the opposite situation. + GCC 4.2 with -std=c99 or -std=gnu99 implements the GNU C inline + semantics but warns, unless -fgnu89-inline is used: + warning: C99 inline functions are not supported; using GNU89 + warning: to disable this warning use -fgnu89-inline or the gnu_inline function attribute + It defines a macro __GNUC_GNU_INLINE__ to indicate this situation. + */ +#if (((defined __APPLE__ && defined __MACH__) \ + || defined __DragonFly__ || defined __FreeBSD__) \ + && (defined HAVE___HEADER_INLINE \ + ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \ + && ! defined __clang__) \ + : ((! defined _DONT_USE_CTYPE_INLINE_ \ + && (defined __GNUC__ || defined __cplusplus)) \ + || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \ + && defined __GNUC__ && ! defined __cplusplus)))) +# define _GL_EXTERN_INLINE_STDHEADER_BUG +#endif +#if ((__GNUC__ \ + ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ + : (199901L <= __STDC_VERSION__ \ + && !defined __HP_cc \ + && !defined __PGI \ + && !(defined __SUNPRO_C && __STDC__))) \ + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) +# define _GL_INLINE inline +# define _GL_EXTERN_INLINE extern inline +# define _GL_EXTERN_INLINE_IN_USE +#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) +# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ + /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ +# define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) +# else +# define _GL_INLINE extern inline +# endif +# define _GL_EXTERN_INLINE extern +# define _GL_EXTERN_INLINE_IN_USE +#else +# define _GL_INLINE _GL_UNUSED static +# define _GL_EXTERN_INLINE _GL_UNUSED static +#endif + +/* In GCC 4.6 (inclusive) to 5.1 (exclusive), + suppress bogus "no previous prototype for 'FOO'" + and "no previous declaration for 'FOO'" diagnostics, + when FOO is an inline function in the header; see + and + . */ +#if __GNUC__ == 4 && 6 <= __GNUC_MINOR__ +# if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ +# define _GL_INLINE_HEADER_CONST_PRAGMA +# else +# define _GL_INLINE_HEADER_CONST_PRAGMA \ + _Pragma ("GCC diagnostic ignored \"-Wsuggest-attribute=const\"") +# endif +# define _GL_INLINE_HEADER_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wmissing-prototypes\"") \ + _Pragma ("GCC diagnostic ignored \"-Wmissing-declarations\"") \ + _GL_INLINE_HEADER_CONST_PRAGMA +# define _GL_INLINE_HEADER_END \ + _Pragma ("GCC diagnostic pop") +#else +# define _GL_INLINE_HEADER_BEGIN +# define _GL_INLINE_HEADER_END +#endif + +/* Define as const if the declaration of iconv() needs const. */ +#undef ICONV_CONST + +/* Define if the host's encoding is EBCDIC. */ +#undef IS_EBCDIC_HOST + +/* Define as the bit index in the word where to find bit 0 of the exponent of + 'long double'. */ +#undef LDBL_EXPBIT0_BIT + +/* Define as the word index where to find the exponent of 'long double'. */ +#undef LDBL_EXPBIT0_WORD + +/* Define as the bit index in the word where to find the sign of 'long + double'. */ +#undef LDBL_SIGNBIT_BIT + +/* Define as the word index where to find the sign of 'long double'. */ +#undef LDBL_SIGNBIT_WORD + +/* Define if localtime() takes a long * not a time_t *. */ +#undef LONG_FOR_TIME_T + +/* Define to a substitute value for mmap()'s MAP_ANONYMOUS flag. */ +#undef MAP_ANONYMOUS + +/* Use GNU style printf and scanf. */ +#ifndef __USE_MINGW_ANSI_STDIO +# undef __USE_MINGW_ANSI_STDIO +#endif + + +/* Define if your C++ doesn't declare gettimeofday(). */ +#undef NEED_DECLARATION_GETTIMEOFDAY + +/* Define if your C++ doesn't declare pclose(). */ +#undef NEED_DECLARATION_PCLOSE + +/* Define if your C++ doesn't declare popen(). */ +#undef NEED_DECLARATION_POPEN + +/* Define if your C++ doesn't declare putenv(). */ +#undef NEED_DECLARATION_PUTENV + +/* Define if your C++ doesn't declare rand(). */ +#undef NEED_DECLARATION_RAND + +/* Define if your C++ doesn't declare srand(). */ +#undef NEED_DECLARATION_SRAND + +/* Define if your C++ doesn't declare strcasecmp(). */ +#undef NEED_DECLARATION_STRCASECMP + +/* Define if your C++ doesn't declare strncasecmp(). */ +#undef NEED_DECLARATION_STRNCASECMP + +/* Define if your C++ doesn't declare vfprintf(). */ +#undef NEED_DECLARATION_VFPRINTF + +/* Define if the vasnprintf implementation needs special code for the 'a' and + 'A' directives. */ +#undef NEED_PRINTF_DIRECTIVE_A + +/* Define if the vasnprintf implementation needs special code for the 'F' + directive. */ +#undef NEED_PRINTF_DIRECTIVE_F + +/* Define if the vasnprintf implementation needs special code for the 'ls' + directive. */ +#undef NEED_PRINTF_DIRECTIVE_LS + +/* Define if the vasnprintf implementation needs special code for 'double' + arguments. */ +#undef NEED_PRINTF_DOUBLE + +/* Define if the vasnprintf implementation needs special code for surviving + out-of-memory conditions. */ +#undef NEED_PRINTF_ENOMEM + +/* Define if the vasnprintf implementation needs special code for the ' flag. + */ +#undef NEED_PRINTF_FLAG_GROUPING + +/* Define if the vasnprintf implementation needs special code for the '-' + flag. */ +#undef NEED_PRINTF_FLAG_LEFTADJUST + +/* Define if the vasnprintf implementation needs special code for the 0 flag. + */ +#undef NEED_PRINTF_FLAG_ZERO + +/* Define if the vasnprintf implementation needs special code for infinite + 'double' arguments. */ +#undef NEED_PRINTF_INFINITE_DOUBLE + +/* Define if the vasnprintf implementation needs special code for infinite + 'long double' arguments. */ +#undef NEED_PRINTF_INFINITE_LONG_DOUBLE + +/* Define if the vasnprintf implementation needs special code for 'long + double' arguments. */ +#undef NEED_PRINTF_LONG_DOUBLE + +/* Define if the vasnprintf implementation needs special code for supporting + large precisions without arbitrary bounds. */ +#undef NEED_PRINTF_UNBOUNDED_PRECISION + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'ptrdiff_t'. */ +#undef PTRDIFF_T_SUFFIX + +/* Define if fprintf is overridden by a POSIX compliant gnulib implementation. + */ +#undef REPLACE_FPRINTF_POSIX + +/* Define if vasnprintf exists but is overridden by gnulib. */ +#undef REPLACE_VASNPRINTF + +/* Define as the return type of signal handlers ('int' or 'void'). */ +#undef RETSIGTYPE + +/* Define if srand() returns void not int. */ +#undef RET_TYPE_SRAND_IS_VOID + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'sig_atomic_t'. */ +#undef SIG_ATOMIC_T_SUFFIX + +/* Define as the maximum value of type 'size_t', if the system doesn't define + it. */ +#ifndef SIZE_MAX +# undef SIZE_MAX +#endif + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'size_t'. */ +#undef SIZE_T_SUFFIX + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#undef STDC_HEADERS + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# undef _ALL_SOURCE +#endif +/* Enable general extensions on macOS. */ +#ifndef _DARWIN_C_SOURCE +# undef _DARWIN_C_SOURCE +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# undef __EXTENSIONS__ +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# undef _GNU_SOURCE +#endif +/* Enable X/Open compliant socket functions that do not require linking + with -lxnet on HP-UX 11.11. */ +#ifndef _HPUX_ALT_XOPEN_SOCKET_API +# undef _HPUX_ALT_XOPEN_SOCKET_API +#endif +/* Identify the host operating system as Minix. + This macro does not affect the system headers' behavior. + A future release of Autoconf may stop defining this macro. */ +#ifndef _MINIX +# undef _MINIX +#endif +/* Enable general extensions on NetBSD. + Enable NetBSD compatibility extensions on Minix. */ +#ifndef _NETBSD_SOURCE +# undef _NETBSD_SOURCE +#endif +/* Enable OpenBSD compatibility extensions on NetBSD. + Oddly enough, this does nothing on OpenBSD. */ +#ifndef _OPENBSD_SOURCE +# undef _OPENBSD_SOURCE +#endif +/* Define to 1 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_SOURCE +# undef _POSIX_SOURCE +#endif +/* Define to 2 if needed for POSIX-compatible behavior. */ +#ifndef _POSIX_1_SOURCE +# undef _POSIX_1_SOURCE +#endif +/* Enable POSIX-compatible threading on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# undef _POSIX_PTHREAD_SEMANTICS +#endif +/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */ +#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */ +#ifndef __STDC_WANT_IEC_60559_BFP_EXT__ +# undef __STDC_WANT_IEC_60559_BFP_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */ +#ifndef __STDC_WANT_IEC_60559_DFP_EXT__ +# undef __STDC_WANT_IEC_60559_DFP_EXT__ +#endif +/* Enable extensions specified by C23 Annex F. */ +#ifndef __STDC_WANT_IEC_60559_EXT__ +# undef __STDC_WANT_IEC_60559_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */ +#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__ +# undef __STDC_WANT_IEC_60559_FUNCS_EXT__ +#endif +/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */ +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# undef __STDC_WANT_IEC_60559_TYPES_EXT__ +#endif +/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */ +#ifndef __STDC_WANT_LIB_EXT2__ +# undef __STDC_WANT_LIB_EXT2__ +#endif +/* Enable extensions specified by ISO/IEC 24747:2009. */ +#ifndef __STDC_WANT_MATH_SPEC_FUNCS__ +# undef __STDC_WANT_MATH_SPEC_FUNCS__ +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# undef _TANDEM_SOURCE +#endif +/* Enable X/Open extensions. Define to 500 only if necessary + to make mbstate_t available. */ +#ifndef _XOPEN_SOURCE +# undef _XOPEN_SOURCE +#endif + + +/* Version number of package */ +#undef VERSION + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'wchar_t'. */ +#undef WCHAR_T_SUFFIX + +/* Define if the 0200 bit of the status returned by wait() indicates whether a + core image was produced for a process that was terminated by a signal. */ +#undef WCOREFLAG + +/* Define to l, ll, u, ul, ull, etc., as suitable for constants of type + 'wint_t'. */ +#undef WINT_T_SUFFIX + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + +/* Define to 1 if the X Window System is missing or not being used. */ +#undef X_DISPLAY_MISSING + +/* True if the compiler says it groks GNU C version MAJOR.MINOR. */ +#if defined __GNUC__ && defined __GNUC_MINOR__ +# define _GL_GNUC_PREREQ(major, minor) \ + ((major) < __GNUC__ + ((minor) <= __GNUC_MINOR__)) +#else +# define _GL_GNUC_PREREQ(major, minor) 0 +#endif + + +/* Define to enable the declarations of ISO C 11 types and functions. */ +#undef _ISOC11_SOURCE + +/* The _Noreturn keyword of C11. */ +#ifndef _Noreturn +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (defined _MSC_VER && 1900 <= _MSC_VER)) \ + && 0) + /* [[noreturn]] is not practically usable, because with it the syntax + extern _Noreturn void func (...); + would not be valid; such a declaration would only be valid with 'extern' + and '_Noreturn' swapped, or without the 'extern' keyword. However, some + AIX system header files and several gnulib header files use precisely + this syntax with 'extern'. */ +# define _Noreturn [[noreturn]] +# elif (defined __clang__ && __clang_major__ < 16 \ + && defined _GL_WORK_AROUND_LLVM_BUG_59792) + /* Compile with -D_GL_WORK_AROUND_LLVM_BUG_59792 to work around + that rare LLVM bug, though you may get many false-alarm warnings. */ +# define _Noreturn +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || (!defined __STRICT_ANSI__ \ + && (_GL_GNUC_PREREQ (4, 7) \ + || (defined __apple_build_version__ \ + ? 6000000 <= __apple_build_version__ \ + : 3 < __clang_major__ + (5 <= __clang_minor__)))))) + /* _Noreturn works as-is. */ +# elif _GL_GNUC_PREREQ (2, 8) || defined __clang__ || 0x5110 <= __SUNPRO_C +# define _Noreturn __attribute__ ((__noreturn__)) +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn +# endif +#endif + + +/* Define if -D_POSIX_SOURCE is necessary. */ +#undef _POSIX_SOURCE + +/* Define if you have ISC 3.x or 4.x. */ +#undef _SYSV3 + +/* For standard stat data types on VMS. */ +#undef _USE_STD_STAT + +/* Define to 1 if the system predates C++11. */ +#undef __STDC_CONSTANT_MACROS + +/* Define to 1 if the system predates C++11. */ +#undef __STDC_LIMIT_MACROS + +/* The _GL_ASYNC_SAFE marker should be attached to functions that are + signal handlers (for signals other than SIGABRT, SIGPIPE) or can be + invoked from such signal handlers. Such functions have some restrictions: + * All functions that it calls should be marked _GL_ASYNC_SAFE as well, + or should be listed as async-signal-safe in POSIX + + section 2.4.3. Note that malloc(), sprintf(), and fwrite(), in + particular, are NOT async-signal-safe. + * All memory locations (variables and struct fields) that these functions + access must be marked 'volatile'. This holds for both read and write + accesses. Otherwise the compiler might optimize away stores to and + reads from such locations that occur in the program, depending on its + data flow analysis. For example, when the program contains a loop + that is intended to inspect a variable set from within a signal handler + while (!signal_occurred) + ; + the compiler is allowed to transform this into an endless loop if the + variable 'signal_occurred' is not declared 'volatile'. + Additionally, recall that: + * A signal handler should not modify errno (except if it is a handler + for a fatal signal and ends by raising the same signal again, thus + provoking the termination of the process). If it invokes a function + that may clobber errno, it needs to save and restore the value of + errno. */ +#define _GL_ASYNC_SAFE + + +/* Attributes. */ +#if (defined __has_attribute \ + && (!defined __clang_minor__ \ + || (defined __apple_build_version__ \ + ? 6000000 <= __apple_build_version__ \ + : 5 <= __clang_major__))) +# define _GL_HAS_ATTRIBUTE(attr) __has_attribute (__##attr##__) +#else +# define _GL_HAS_ATTRIBUTE(attr) _GL_ATTR_##attr +# define _GL_ATTR_alloc_size _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_always_inline _GL_GNUC_PREREQ (3, 2) +# define _GL_ATTR_artificial _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_cold _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_const _GL_GNUC_PREREQ (2, 95) +# define _GL_ATTR_deprecated _GL_GNUC_PREREQ (3, 1) +# define _GL_ATTR_diagnose_if 0 +# define _GL_ATTR_error _GL_GNUC_PREREQ (4, 3) +# define _GL_ATTR_externally_visible _GL_GNUC_PREREQ (4, 1) +# define _GL_ATTR_fallthrough _GL_GNUC_PREREQ (7, 0) +# define _GL_ATTR_format _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_leaf _GL_GNUC_PREREQ (4, 6) +# define _GL_ATTR_malloc _GL_GNUC_PREREQ (3, 0) +# ifdef _ICC +# define _GL_ATTR_may_alias 0 +# else +# define _GL_ATTR_may_alias _GL_GNUC_PREREQ (3, 3) +# endif +# define _GL_ATTR_noinline _GL_GNUC_PREREQ (3, 1) +# define _GL_ATTR_nonnull _GL_GNUC_PREREQ (3, 3) +# define _GL_ATTR_nonstring _GL_GNUC_PREREQ (8, 0) +# define _GL_ATTR_nothrow _GL_GNUC_PREREQ (3, 3) +# define _GL_ATTR_packed _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_pure _GL_GNUC_PREREQ (2, 96) +# define _GL_ATTR_returns_nonnull _GL_GNUC_PREREQ (4, 9) +# define _GL_ATTR_sentinel _GL_GNUC_PREREQ (4, 0) +# define _GL_ATTR_unused _GL_GNUC_PREREQ (2, 7) +# define _GL_ATTR_warn_unused_result _GL_GNUC_PREREQ (3, 4) +#endif + +/* Disable GCC -Wpedantic if using __has_c_attribute and this is not C23+. */ +#if (defined __has_c_attribute && _GL_GNUC_PREREQ (4, 6) \ + && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) <= 201710) +# pragma GCC diagnostic ignored "-Wpedantic" +#endif + + +/* _GL_ATTRIBUTE_ALLOC_SIZE ((N)) declares that the Nth argument of the function + is the size of the returned memory block. + _GL_ATTRIBUTE_ALLOC_SIZE ((M, N)) declares that the Mth argument multiplied + by the Nth argument of the function is the size of the returned memory block. + */ +/* Applies to: function, pointer to function, function types. */ +#ifndef _GL_ATTRIBUTE_ALLOC_SIZE +# if _GL_HAS_ATTRIBUTE (alloc_size) +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args)) +# else +# define _GL_ATTRIBUTE_ALLOC_SIZE(args) +# endif +#endif + +/* _GL_ATTRIBUTE_ALWAYS_INLINE tells that the compiler should always inline the + function and report an error if it cannot do so. */ +/* Applies to: function. */ +#ifndef _GL_ATTRIBUTE_ALWAYS_INLINE +# if _GL_HAS_ATTRIBUTE (always_inline) +# define _GL_ATTRIBUTE_ALWAYS_INLINE __attribute__ ((__always_inline__)) +# else +# define _GL_ATTRIBUTE_ALWAYS_INLINE +# endif +#endif + +/* _GL_ATTRIBUTE_ARTIFICIAL declares that the function is not important to show + in stack traces when debugging. The compiler should omit the function from + stack traces. */ +/* Applies to: function. */ +#ifndef _GL_ATTRIBUTE_ARTIFICIAL +# if _GL_HAS_ATTRIBUTE (artificial) +# define _GL_ATTRIBUTE_ARTIFICIAL __attribute__ ((__artificial__)) +# else +# define _GL_ATTRIBUTE_ARTIFICIAL +# endif +#endif + +/* _GL_ATTRIBUTE_COLD declares that the function is rarely executed. */ +/* Applies to: functions. */ +/* Avoid __attribute__ ((cold)) on MinGW; see thread starting at + . + Also, Oracle Studio 12.6 requires 'cold' not '__cold__'. */ +#ifndef _GL_ATTRIBUTE_COLD +# if _GL_HAS_ATTRIBUTE (cold) && !defined __MINGW32__ +# ifndef __SUNPRO_C +# define _GL_ATTRIBUTE_COLD __attribute__ ((__cold__)) +# else +# define _GL_ATTRIBUTE_COLD __attribute__ ((cold)) +# endif +# else +# define _GL_ATTRIBUTE_COLD +# endif +#endif + +/* _GL_ATTRIBUTE_CONST declares that it is OK for a compiler to omit duplicate + calls to the function with the same arguments. + This attribute is safe for a function that neither depends on nor affects + observable state, and always returns exactly once - e.g., does not loop + forever, and does not call longjmp. + (This attribute is stricter than _GL_ATTRIBUTE_PURE.) */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_CONST +# if _GL_HAS_ATTRIBUTE (const) +# define _GL_ATTRIBUTE_CONST __attribute__ ((__const__)) +# else +# define _GL_ATTRIBUTE_CONST +# endif +#endif + +/* _GL_ATTRIBUTE_DEALLOC (F, I) declares that the function returns pointers + that can be freed by passing them as the Ith argument to the + function F. + _GL_ATTRIBUTE_DEALLOC_FREE declares that the function returns pointers that + can be freed via 'free'; it can be used only after declaring 'free'. */ +/* Applies to: functions. Cannot be used on inline functions. */ +#ifndef _GL_ATTRIBUTE_DEALLOC +# if _GL_GNUC_PREREQ (11, 0) +# define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) +# else +# define _GL_ATTRIBUTE_DEALLOC(f, i) +# endif +#endif +/* If gnulib's or has already defined this macro, continue + to use this earlier definition, since may not have been included + yet. */ +#ifndef _GL_ATTRIBUTE_DEALLOC_FREE +# if defined __cplusplus && defined __GNUC__ && !defined __clang__ +/* Work around GCC bug */ +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC ((void (*) (void *)) free, 1) +# else +# define _GL_ATTRIBUTE_DEALLOC_FREE \ + _GL_ATTRIBUTE_DEALLOC (free, 1) +# endif +#endif + +/* _GL_ATTRIBUTE_DEPRECATED: Declares that an entity is deprecated. + The compiler may warn if the entity is used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: namespace, class, template specialization. */ +#ifndef _GL_ATTRIBUTE_DEPRECATED +# ifdef __has_c_attribute +# if __has_c_attribute (__deprecated__) +# define _GL_ATTRIBUTE_DEPRECATED [[__deprecated__]] +# endif +# endif +# if !defined _GL_ATTRIBUTE_DEPRECATED && _GL_HAS_ATTRIBUTE (deprecated) +# define _GL_ATTRIBUTE_DEPRECATED __attribute__ ((__deprecated__)) +# endif +# ifndef _GL_ATTRIBUTE_DEPRECATED +# define _GL_ATTRIBUTE_DEPRECATED +# endif +#endif + +/* _GL_ATTRIBUTE_ERROR(msg) requests an error if a function is called and + the function call is not optimized away. + _GL_ATTRIBUTE_WARNING(msg) requests a warning if a function is called and + the function call is not optimized away. */ +/* Applies to: functions. */ +#if !(defined _GL_ATTRIBUTE_ERROR && defined _GL_ATTRIBUTE_WARNING) +# if _GL_HAS_ATTRIBUTE (error) +# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__error__ (msg))) +# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__warning__ (msg))) +# elif _GL_HAS_ATTRIBUTE (diagnose_if) +# define _GL_ATTRIBUTE_ERROR(msg) __attribute__ ((__diagnose_if__ (1, msg, "error"))) +# define _GL_ATTRIBUTE_WARNING(msg) __attribute__ ((__diagnose_if__ (1, msg, "warning"))) +# else +# define _GL_ATTRIBUTE_ERROR(msg) +# define _GL_ATTRIBUTE_WARNING(msg) +# endif +#endif + +/* _GL_ATTRIBUTE_EXTERNALLY_VISIBLE declares that the entity should remain + visible to debuggers etc., even with '-fwhole-program'. */ +/* Applies to: functions, variables. */ +#ifndef _GL_ATTRIBUTE_EXTERNALLY_VISIBLE +# if _GL_HAS_ATTRIBUTE (externally_visible) +# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE __attribute__ ((externally_visible)) +# else +# define _GL_ATTRIBUTE_EXTERNALLY_VISIBLE +# endif +#endif + +/* _GL_ATTRIBUTE_FALLTHROUGH declares that it is not a programming mistake if + the control flow falls through to the immediately following 'case' or + 'default' label. The compiler should not warn in this case. */ +/* Applies to: Empty statement (;), inside a 'switch' statement. */ +/* Always expands to something. */ +#ifndef _GL_ATTRIBUTE_FALLTHROUGH +# ifdef __has_c_attribute +# if __has_c_attribute (__fallthrough__) +# define _GL_ATTRIBUTE_FALLTHROUGH [[__fallthrough__]] +# endif +# endif +# if !defined _GL_ATTRIBUTE_FALLTHROUGH && _GL_HAS_ATTRIBUTE (fallthrough) +# define _GL_ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__)) +# endif +# ifndef _GL_ATTRIBUTE_FALLTHROUGH +# define _GL_ATTRIBUTE_FALLTHROUGH ((void) 0) +# endif +#endif + +/* _GL_ATTRIBUTE_FORMAT ((ARCHETYPE, STRING-INDEX, FIRST-TO-CHECK)) + declares that the STRING-INDEXth function argument is a format string of + style ARCHETYPE, which is one of: + printf, gnu_printf + scanf, gnu_scanf, + strftime, gnu_strftime, + strfmon, + or the same thing prefixed and suffixed with '__'. + If FIRST-TO-CHECK is not 0, arguments starting at FIRST-TO_CHECK + are suitable for the format string. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_FORMAT +# if _GL_HAS_ATTRIBUTE (format) +# define _GL_ATTRIBUTE_FORMAT(spec) __attribute__ ((__format__ spec)) +# else +# define _GL_ATTRIBUTE_FORMAT(spec) +# endif +#endif + +/* _GL_ATTRIBUTE_LEAF declares that if the function is called from some other + compilation unit, it executes code from that unit only by return or by + exception handling. This declaration lets the compiler optimize that unit + more aggressively. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_LEAF +# if _GL_HAS_ATTRIBUTE (leaf) +# define _GL_ATTRIBUTE_LEAF __attribute__ ((__leaf__)) +# else +# define _GL_ATTRIBUTE_LEAF +# endif +#endif + +/* _GL_ATTRIBUTE_MALLOC declares that the function returns a pointer to freshly + allocated memory. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_MALLOC +# if _GL_HAS_ATTRIBUTE (malloc) +# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) +# else +# define _GL_ATTRIBUTE_MALLOC +# endif +#endif + +/* _GL_ATTRIBUTE_MAY_ALIAS declares that pointers to the type may point to the + same storage as pointers to other types. Thus this declaration disables + strict aliasing optimization. */ +/* Applies to: types. */ +/* Oracle Studio 12.6 mishandles may_alias despite __has_attribute OK. */ +#ifndef _GL_ATTRIBUTE_MAY_ALIAS +# if _GL_HAS_ATTRIBUTE (may_alias) && !defined __SUNPRO_C +# define _GL_ATTRIBUTE_MAY_ALIAS __attribute__ ((__may_alias__)) +# else +# define _GL_ATTRIBUTE_MAY_ALIAS +# endif +#endif + +/* _GL_ATTRIBUTE_MAYBE_UNUSED declares that it is not a programming mistake if + the entity is not used. The compiler should not warn if the entity is not + used. */ +/* Applies to: + - function, variable, + - struct, union, struct/union member, + - enumeration, enumeration item, + - typedef, + in C++ also: class. */ +/* In C++ and C23, this is spelled [[__maybe_unused__]]. + GCC's syntax is __attribute__ ((__unused__)). + clang supports both syntaxes. Except that with clang ≥ 6, < 10, in C++ mode, + __has_c_attribute (__maybe_unused__) yields true but the use of + [[__maybe_unused__]] nevertheless produces a warning. */ +#ifndef _GL_ATTRIBUTE_MAYBE_UNUSED +# if defined __clang__ && defined __cplusplus +# if __clang_major__ >= 10 +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif +# elif defined __has_c_attribute +# if __has_c_attribute (__maybe_unused__) +# define _GL_ATTRIBUTE_MAYBE_UNUSED [[__maybe_unused__]] +# endif +# endif +# ifndef _GL_ATTRIBUTE_MAYBE_UNUSED +# define _GL_ATTRIBUTE_MAYBE_UNUSED _GL_ATTRIBUTE_UNUSED +# endif +#endif +/* Alternative spelling of this macro, for convenience and for + compatibility with glibc/include/libc-symbols.h. */ +#define _GL_UNUSED _GL_ATTRIBUTE_MAYBE_UNUSED +/* Earlier spellings of this macro. */ +#define _UNUSED_PARAMETER_ _GL_ATTRIBUTE_MAYBE_UNUSED + +/* _GL_ATTRIBUTE_NODISCARD declares that the caller of the function should not + discard the return value. The compiler may warn if the caller does not use + the return value, unless the caller uses something like ignore_value. */ +/* Applies to: function, enumeration, class. */ +#ifndef _GL_ATTRIBUTE_NODISCARD +# if defined __clang__ && defined __cplusplus + /* With clang up to 15.0.6 (at least), in C++ mode, [[__nodiscard__]] produces + a warning. + The 1000 below means a yet unknown threshold. When clang++ version X + starts supporting [[__nodiscard__]] without warning about it, you can + replace the 1000 with X. */ +# if __clang_major__ >= 1000 +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# endif +# elif defined __has_c_attribute +# if __has_c_attribute (__nodiscard__) +# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]] +# endif +# endif +# if !defined _GL_ATTRIBUTE_NODISCARD && _GL_HAS_ATTRIBUTE (warn_unused_result) +# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__)) +# endif +# ifndef _GL_ATTRIBUTE_NODISCARD +# define _GL_ATTRIBUTE_NODISCARD +# endif +#endif + +/* _GL_ATTRIBUTE_NOINLINE tells that the compiler should not inline the + function. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_NOINLINE +# if _GL_HAS_ATTRIBUTE (noinline) +# define _GL_ATTRIBUTE_NOINLINE __attribute__ ((__noinline__)) +# else +# define _GL_ATTRIBUTE_NOINLINE +# endif +#endif + +/* _GL_ATTRIBUTE_NONNULL ((N1, N2,...)) declares that the arguments N1, N2,... + must not be NULL. + _GL_ATTRIBUTE_NONNULL () declares that all pointer arguments must not be + null. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_NONNULL +# if _GL_HAS_ATTRIBUTE (nonnull) +# define _GL_ATTRIBUTE_NONNULL(args) __attribute__ ((__nonnull__ args)) +# else +# define _GL_ATTRIBUTE_NONNULL(args) +# endif +#endif + +/* _GL_ATTRIBUTE_NONSTRING declares that the contents of a character array is + not meant to be NUL-terminated. */ +/* Applies to: struct/union members and variables that are arrays of element + type '[[un]signed] char'. */ +#ifndef _GL_ATTRIBUTE_NONSTRING +# if _GL_HAS_ATTRIBUTE (nonstring) +# define _GL_ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) +# else +# define _GL_ATTRIBUTE_NONSTRING +# endif +#endif + +/* There is no _GL_ATTRIBUTE_NORETURN; use _Noreturn instead. */ + +/* _GL_ATTRIBUTE_NOTHROW declares that the function does not throw exceptions. + */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_NOTHROW +# if _GL_HAS_ATTRIBUTE (nothrow) && !defined __cplusplus +# define _GL_ATTRIBUTE_NOTHROW __attribute__ ((__nothrow__)) +# else +# define _GL_ATTRIBUTE_NOTHROW +# endif +#endif + +/* _GL_ATTRIBUTE_PACKED declares: + For struct members: The member has the smallest possible alignment. + For struct, union, class: All members have the smallest possible alignment, + minimizing the memory required. */ +/* Applies to: struct members, struct, union, + in C++ also: class. */ +#ifndef _GL_ATTRIBUTE_PACKED +# if _GL_HAS_ATTRIBUTE (packed) +# define _GL_ATTRIBUTE_PACKED __attribute__ ((__packed__)) +# else +# define _GL_ATTRIBUTE_PACKED +# endif +#endif + +/* _GL_ATTRIBUTE_PURE declares that It is OK for a compiler to omit duplicate + calls to the function with the same arguments if observable state is not + changed between calls. + This attribute is safe for a function that does not affect + observable state, and always returns exactly once. + (This attribute is looser than _GL_ATTRIBUTE_CONST.) */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_PURE +# if _GL_HAS_ATTRIBUTE (pure) +# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__)) +# else +# define _GL_ATTRIBUTE_PURE +# endif +#endif + +/* _GL_ATTRIBUTE_RETURNS_NONNULL declares that the function's return value is + a non-NULL pointer. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_RETURNS_NONNULL +# if _GL_HAS_ATTRIBUTE (returns_nonnull) +# define _GL_ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__)) +# else +# define _GL_ATTRIBUTE_RETURNS_NONNULL +# endif +#endif + +/* _GL_ATTRIBUTE_SENTINEL(pos) declares that the variadic function expects a + trailing NULL argument. + _GL_ATTRIBUTE_SENTINEL () - The last argument is NULL (requires C99). + _GL_ATTRIBUTE_SENTINEL ((N)) - The (N+1)st argument from the end is NULL. */ +/* Applies to: functions. */ +#ifndef _GL_ATTRIBUTE_SENTINEL +# if _GL_HAS_ATTRIBUTE (sentinel) +# define _GL_ATTRIBUTE_SENTINEL(pos) __attribute__ ((__sentinel__ pos)) +# else +# define _GL_ATTRIBUTE_SENTINEL(pos) +# endif +#endif + +/* A helper macro. Don't use it directly. */ +#ifndef _GL_ATTRIBUTE_UNUSED +# if _GL_HAS_ATTRIBUTE (unused) +# define _GL_ATTRIBUTE_UNUSED __attribute__ ((__unused__)) +# else +# define _GL_ATTRIBUTE_UNUSED +# endif +#endif + + +/* _GL_UNUSED_LABEL; declares that it is not a programming mistake if the + immediately preceding label is not used. The compiler should not warn + if the label is not used. */ +/* Applies to: label (both in C and C++). */ +/* Note that g++ < 4.5 does not support the '__attribute__ ((__unused__)) ;' + syntax. But clang does. */ +#ifndef _GL_UNUSED_LABEL +# if !(defined __cplusplus && !_GL_GNUC_PREREQ (4, 5)) || defined __clang__ +# define _GL_UNUSED_LABEL _GL_ATTRIBUTE_UNUSED +# else +# define _GL_UNUSED_LABEL +# endif +#endif + + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to long or long long if and don't define. */ +#undef intmax_t + +/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports + the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of + earlier versions), but does not display it by setting __GNUC_STDC_INLINE__. + __APPLE__ && __MACH__ test for Mac OS X. + __APPLE_CC__ tests for the Apple compiler and its version. + __STDC_VERSION__ tests for the C99 mode. */ +#if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined __cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__ +# define __GNUC_STDC_INLINE__ 1 +#endif + +/* _GL_CMP (n1, n2) performs a three-valued comparison on n1 vs. n2, where + n1 and n2 are expressions without side effects, that evaluate to real + numbers (excluding NaN). + It returns + 1 if n1 > n2 + 0 if n1 == n2 + -1 if n1 < n2 + The naïve code (n1 > n2 ? 1 : n1 < n2 ? -1 : 0) produces a conditional + jump with nearly all GCC versions up to GCC 10. + This variant (n1 < n2 ? -1 : n1 > n2) produces a conditional with many + GCC versions up to GCC 9. + The better code (n1 > n2) - (n1 < n2) from Hacker's Delight § 2-9 + avoids conditional jumps in all GCC versions >= 3.4. */ +#define _GL_CMP(n1, n2) (((n1) > (n2)) - ((n1) < (n2))) + + +/* Define to `int' if does not define. */ +#undef mode_t + +/* Define as a signed integer type capable of holding a process identifier. */ +#undef pid_t + +/* Define as the type of the result of subtracting two pointers, if the system + doesn't define it. */ +#undef ptrdiff_t + +/* Define to the equivalent of the C99 'restrict' keyword, or to + nothing if this is not supported. Do not define if restrict is + supported only directly. */ +#undef restrict +/* Work around a bug in older versions of Sun C++, which did not + #define __restrict__ or support _Restrict or __restrict__ + even though the corresponding Sun C compiler ended up with + "#define restrict _Restrict" or "#define restrict __restrict__" + in the previous line. This workaround can be removed once + we assume Oracle Developer Studio 12.5 (2016) or later. */ +#if defined __SUNPRO_CC && !defined __RESTRICT && !defined __restrict__ +# define _Restrict +# define __restrict__ +#endif + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define as a signed type of the same size as size_t. */ +#undef ssize_t + +/* Define uintmax_t to 'unsigned long' or 'unsigned long long' if + does not exist. */ +#undef uintmax_t + + + /* This definition is a duplicate of the one in unitypes.h. + It is here so that we can cope with an older version of unitypes.h + that does not contain this definition and that is pre-installed among + the public header files. */ + # if defined __restrict \ + || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ + || __clang_major__ >= 3 + # define _UC_RESTRICT __restrict + # elif 199901L <= __STDC_VERSION__ || defined restrict + # define _UC_RESTRICT restrict + # else + # define _UC_RESTRICT + # endif + + +#if (!defined HAVE_C_STATIC_ASSERT && !defined assert \ + && (!defined __cplusplus \ + || (__cpp_static_assert < 201411 \ + && __GNUG__ < 6 && __clang_major__ < 6))) + #include + #undef/**/assert + /* Solaris 11.4 defines static_assert as a macro with 2 arguments. + We need it also to be invocable with a single argument. */ + #if defined __sun && (__STDC_VERSION__ - 0 >= 201112L) && !defined __cplusplus + #undef/**/static_assert + #define static_assert _Static_assert + #endif +#endif diff --git a/src/include/cset.h b/src/include/cset.h new file mode 100644 index 0000000..996e9a8 --- /dev/null +++ b/src/include/cset.h @@ -0,0 +1,74 @@ +// -*- C++ -*- +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +#ifdef HAVE_CC_LIMITS_H +#include +#else /* not HAVE_CC_LIMITS_H */ +#ifndef UCHAR_MAX +#define UCHAR_MAX 255 +#endif +#endif /* not HAVE_CC_LIMITS_H */ + +enum cset_builtin { CSET_BUILTIN }; + +class cset { +public: + cset(); + cset(cset_builtin); + cset(const char *); + cset(const unsigned char *); + int operator()(unsigned char) const; + + cset &operator|=(const cset &); + cset &operator|=(unsigned char); + + friend class cset_init; +private: + char v[UCHAR_MAX+1]; + void clear(); +}; + +inline int cset::operator()(unsigned char c) const +{ + return v[c]; +} + +inline cset &cset::operator|=(unsigned char c) +{ + v[c] = 1; + return *this; +} + +extern cset csalpha; +extern cset csupper; +extern cset cslower; +extern cset csdigit; +extern cset csxdigit; +extern cset csspace; +extern cset cspunct; +extern cset csalnum; +extern cset csprint; +extern cset csgraph; +extern cset cscntrl; + +static class cset_init { + static int initialised; +public: + cset_init(); +} _cset_init; diff --git a/src/include/curtime.h b/src/include/curtime.h new file mode 100644 index 0000000..5d3a24a --- /dev/null +++ b/src/include/curtime.h @@ -0,0 +1,27 @@ +/* Copyright (C) 2015-2020 Free Software Foundation, Inc. + +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 of the License, 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. + +The GNU General Public License version 2 (GPL2) is available in the +internet at . */ + +#ifndef LONG_FOR_TIME_T +#include +#endif + +#ifdef LONG_FOR_TIME_T +long +#else +time_t +#endif +current_time(); diff --git a/src/include/device.h b/src/include/device.h new file mode 100644 index 0000000..6543292 --- /dev/null +++ b/src/include/device.h @@ -0,0 +1,25 @@ +// -*- C++ -*- +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +// The target device. Once initialized, the device doesn't change during +// the entire program run. Sample devices are 'ps' (for Postscript), 'html' +// (for HTML), and 'ascii', 'latin1', 'utf8' for TTY output. +extern const char *device; + +// end of device.h diff --git a/src/include/driver.h b/src/include/driver.h new file mode 100644 index 0000000..965ac1a --- /dev/null +++ b/src/include/driver.h @@ -0,0 +1,38 @@ +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +#include "lib.h" + +#include +#include +#include +#include +#include +#include "errarg.h" +#include "error.h" +#include "font.h" +#include "printer.h" +#include "geometry.h" + +void do_file(const char *); + +// Local Variables: +// fill-column: 72 +// mode: C++ +// End: +// vim: set cindent noexpandtab shiftwidth=2 textwidth=72: diff --git a/src/include/errarg.h b/src/include/errarg.h new file mode 100644 index 0000000..67a5852 --- /dev/null +++ b/src/include/errarg.h @@ -0,0 +1,46 @@ +// -*- C++ -*- +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +class errarg { + enum { EMPTY, STRING, CHAR, INTEGER, UNSIGNED_INTEGER, DOUBLE } type; + union { + const char *s; + int n; + unsigned int u; + char c; + double d; + }; + public: + errarg(); + errarg(const char *); + errarg(char); + errarg(unsigned char); + errarg(int); + errarg(unsigned int); + errarg(double); + int empty() const; + void print() const; +}; + +extern errarg empty_errarg; + +extern void errprint(const char *, + const errarg &arg1 = empty_errarg, + const errarg &arg2 = empty_errarg, + const errarg &arg3 = empty_errarg); diff --git a/src/include/error.h b/src/include/error.h new file mode 100644 index 0000000..77302f8 --- /dev/null +++ b/src/include/error.h @@ -0,0 +1,69 @@ +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +void fatal_with_file_and_line(const char *, int, const char *, + const errarg & = empty_errarg, + const errarg & = empty_errarg, + const errarg & = empty_errarg); + +void error_with_file_and_line(const char *, int, const char *, + const errarg & = empty_errarg, + const errarg & = empty_errarg, + const errarg & = empty_errarg); + +void warning_with_file_and_line(const char *, int, const char *, + const errarg & = empty_errarg, + const errarg & = empty_errarg, + const errarg & = empty_errarg); + +void debug_with_file_and_line(const char *, int, const char *, + const errarg & = empty_errarg, + const errarg & = empty_errarg, + const errarg & = empty_errarg); + +void fatal(const char *, + const errarg & = empty_errarg, + const errarg & = empty_errarg, + const errarg & = empty_errarg); + +void error(const char *, + const errarg & = empty_errarg, + const errarg & = empty_errarg, + const errarg & = empty_errarg); + +void warning(const char *, + const errarg & = empty_errarg, + const errarg & = empty_errarg, + const errarg & = empty_errarg); + +void debug(const char *, + const errarg & = empty_errarg, + const errarg & = empty_errarg, + const errarg & = empty_errarg); + + +extern "C" const char *program_name; +extern int current_lineno; +extern const char *current_filename; +extern const char *current_source_filename; + +// Local Variables: +// fill-column: 72 +// mode: C++ +// End: +// vim: set cindent noexpandtab shiftwidth=2 textwidth=72: diff --git a/src/include/font.h b/src/include/font.h new file mode 100644 index 0000000..68a82fa --- /dev/null +++ b/src/include/font.h @@ -0,0 +1,343 @@ +// -*- C++ -*- +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +// A function of this type can be registered to define the semantics of +// arbitrary commands in a font DESC file. +typedef void (*FONT_COMMAND_HANDLER)(const char *, // command + const char *, // arg + const char *, // file + int); // lineno + +// A glyph is represented by a font-independent 'glyph *' pointer. The +// functions name_to_glyph and number_to_glyph return such a pointer. +// +// There are two types of glyphs: +// +// - those with a name, and among these in particular: +// 'charNNN' denoting a single 'char' in the input character set, +// 'uXXXX' denoting a Unicode character, +// +// - those with a number, referring to the font-dependent glyph with +// the given number. + +// The statically allocated information about a glyph. +// +// This is an abstract class; only its subclass 'charinfo' is +// instantiated. 'charinfo' exists in two versions: one in +// roff/troff/input.cpp for troff, and one in +// libs/libgroff/nametoindex.cpp for the preprocessors and the +// postprocessors. +struct glyph { + int index; // A font-independent integer value. + int number; // Glyph number or -1. + friend class character_indexer; +}; + +#define UNDEFINED_GLYPH ((glyph *) 0) + +// The next three functions exist in two versions: one in +// roff/troff/input.cpp for troff, and one in +// libs/libgroff/nametoindex.cpp for the preprocessors and the +// postprocessors. +extern glyph *name_to_glyph(const char *); // Convert the glyph with + // the given name (arg1) to a 'glyph' object. This + // has the same semantics as the groff escape sequence + // \C'name'. If such a 'glyph' object does not yet + // exist, a new one is allocated. +extern glyph *number_to_glyph(int); // Convert the font-dependent glyph + // with the given number (in the font) to a 'glyph' + // object. This has the same semantics as the groff + // escape sequence \N'number'. If such a 'glyph' + // object does not yet exist, a new one is allocated. +extern const char *glyph_to_name(glyph *); // Convert the given + // glyph back to its name. Return null pointer + // if the glyph doesn't have a name. +inline int glyph_to_number(glyph *); // Convert the given glyph back to + // its number. Return -1 if it does not designate + // a numbered character. +inline int glyph_to_index(glyph *); // Return the unique index that is + // associated with the given glyph. It is >= 0. +extern int glyph_to_unicode(glyph *); // Convert the given glyph to its + // Unicode codepoint. Return -1 if it does not + // designate a Unicode character. + +inline int glyph_to_number(glyph *g) +{ + return g->number; +} + +inline int glyph_to_index(glyph *g) +{ + return g->index; +} + +// Types used in non-public members of 'class font'. +struct font_kern_list; +struct font_char_metric; +struct font_widths_cache; + +// A 'class font' instance represents the relevant information of a font of +// the given device. This includes the set of glyphs represented by the +// font, and metrics for each glyph. +class font { +public: + enum { // The valid argument values of 'has_ligature'. + LIG_ff = 1, + LIG_fi = 2, + LIG_fl = 4, + LIG_ffi = 8, + LIG_ffl = 16 + }; + + virtual ~font(); // Destructor. + bool contains(glyph *); // This font contains the given glyph. + bool is_special(); // This font is searched for glyphs not defined + // in the current font. See section 'Special + // Fonts' in the groff Texinfo manual. Used by + // make_glyph_node(). + int get_width(glyph *, int); // A rectangle represents the shape of the + // given glyph (arg1) at the given point size + // (arg2). Return the horizontal dimension of this + // rectangle. + int get_height(glyph *, int); // A rectangle represents the shape of the + // given glyph (arg1) at the given point size + // (arg2). Return the distance between the base + // line and the top of this rectangle. + // This is often also called the 'ascent' of the + // glyph. If the top is above the baseline, this + // value is positive. + int get_depth(glyph *, int); // A rectangle represents the shape of the + // given glyph (arg1) at the given point size + // (arg2). Return the distance between the base + // line and the bottom of this rectangle. + // This is often also called the 'descent' of the + // glyph. If the bottom is below the baseline, + // this value is positive. + int get_space_width(int); // Return the normal width of a space at the + // given point size. + int get_character_type(glyph *); // Return a bit mask describing the + // shape of the given glyph. Bit 0 is set if the + // character has a descender. Bit 1 is set if the + // character has a tall glyph. See groff manual, + // description of \w and the 'ct' register. + int get_kern(glyph *, glyph *, int); // Return the kerning between the + // given glyphs (arg1 and arg2), both at the given + // point size (arg3). + int get_skew(glyph *, int, int); // A rectangle represents the shape + // of the given glyph (arg1) at the given point size + // (arg2). For slanted fonts like Times-Italic, the + // optical vertical axis is naturally slanted. The + // natural slant value (measured in degrees; + // positive values mean aslant to the right) is + // specified in the font's description file (see + // member variable SLANT below). In addition to + // this, any font can be artificially slanted. This + // artificial slant value (arg3, measured in + // degrees; positive values mean a slant to the + // right) is specified with the \S escape. + // + // Return the skew value which is the horizontal + // distance between the upper left corner of the + // glyph box and the upper left corner of the glyph + // box thought to be slanted by the sum of the + // natural and artificial slant. It basically means + // how much an accent must be shifted horizontally + // to put it on the optical axis of the glyph. + bool has_ligature(int); // This font has the given ligature type + // (one of LIG_ff, LIG_fi, ...). + int get_italic_correction(glyph *, int); // If the given glyph (arg1) + // at the given point size (arg2) is followed by an + // unslanted glyph, some horizontal white space may + // need to be inserted in between. See the groff + // manual, description of \/. Return the amount + // (width) of this white space. + int get_left_italic_correction(glyph *, int); // If the given glyph (arg1) + // at the given point size (arg2) is preceded by an + // unslanted roman glyph, some horizontal white + // space may need to be inserted in between. See + // the groff manual, description of \,. Return the + // amount (width) of this white space. + int get_subscript_correction(glyph *, int); // If the given glyph (arg1) + // at the given point size (arg2)is followed by a + // subscript glyph, the horizontal position may need + // to be advanced by some (possibly negative) + // amount. See groff manual, description of \w and + // the 'ssc' register. Return this amount. + void set_zoom(int); // Set the font's zoom factor * 1000. Must be a + // non-negative value. + int get_zoom(); // Return the font's zoom factor * 1000. + int get_code(glyph *); // Return the code point in the physical + // font of the given glyph. + const char *get_special_device_encoding(glyph *); // Return + // special device-dependent information about + // the given glyph. Return null pointer if + // there is no special information. + const char *get_name(); // Return the name of this font. + const char *get_internal_name(); // Return the 'internalname' + // attribute of this font or null pointer if it + // has none. + const char *get_image_generator(); // Return the 'image_generator' + // attribute of this font or null pointer if it + // has none. + static bool scan_papersize(const char *, const char **, + double *, double *); // Parse the + // 'papersize' directive in the DESC file name + // given in arg1. Update arg2 with the name + // of the paper format and arg3 and arg4 with + // its length and width, respectively. Return + // whether paper size was successfully set. + static font *load_font(const char *, bool = false); // Load the font + // description file with the given name (arg1) + // and return a pointer to a 'font' object. If + // arg2 is true, only the part of the font + // description file before the 'charset' and + // 'kernpairs' sections is loaded. Return null + // pointer in case of failure. + static void command_line_font_dir(const char *); // Prepend given + // path (arg1) to the list of directories in which + // to look up fonts. + static FILE *open_file(const char *, char **); // Open + // a font file with the given name (arg1), + // searching along the current font path. If + // arg2 points to a string pointer, set it to + // the found file name (this depends on the + // device also). Return the opened file. If + // not found, arg2 is unchanged, and a null + // pointer is returned. + + // Open the DESC file (depending on the device) and initialize some + // static variables with info from there. + static const char *load_desc(); + static FONT_COMMAND_HANDLER + set_unknown_desc_command_handler(FONT_COMMAND_HANDLER); // Register + // a function which defines the semantics of + // arbitrary commands in the font DESC file. + // Now the variables from the DESC file, shared by all fonts. + static int res; // The 'res' attribute given in the DESC file. + static int hor; // The 'hor' attribute given in the DESC file. + static int vert; // The 'vert' attribute given in the DESC file. + static int unitwidth; // The 'unitwidth' attribute given in the DESC file. + static int paperwidth; // The 'paperwidth' attribute given in the + // DESC file, or derived from the 'papersize' + // attribute given in the DESC file. + static int paperlength; // The 'paperlength' attribute given in the + // DESC file, or derived from the 'papersize' + // attribute given in the DESC file. + static const char *papersize; + static int biggestfont; // The 'biggestfont' attribute given in the + // DESC file. + static int spare2; + static int sizescale; // The 'sizescale' attribute given in the DESC file. + static bool has_tcommand; // DESC file has 'tcommand' directive. + static bool use_unscaled_charwidths; // DESC file has + // 'unscaled_charwidths' directive. + static bool pass_filenames; // DESC file has 'pass_filenames' + // directive. + static bool use_charnames_in_special; // DESC file has + // 'use_charnames_in_special' directive. + static bool is_unicode; // DESC file has the 'unicode' directive. + static const char *image_generator; // The 'image_generator' attribute + // given in the DESC file. + static const char **font_name_table; // The 'fonts' attribute given + // in the DESC file, as a null + // pointer-terminated array of strings. + static const char **style_table; // The 'styles' attribute given + // in the DESC file, as a null + // pointer-terminated array of strings. + static const char *family; // The 'family' attribute given in the DESC + // file. + static int *sizes; // The 'sizes' attribute given in the DESC file, as + // an array of intervals of the form { lower1, + // upper1, ... lowerN, upperN, 0 }. + +private: + unsigned ligatures; // Bit mask of available ligatures. Used by + // has_ligature(). + font_kern_list **kern_hash_table; // Hash table of kerning pairs. + // Used by get_kern(). + int space_width; // The normal width of a space. Used by + // get_space_width(). + bool special; // See public is_special() above. + char *name; // The name of this font. Used by get_name(). + char *internalname; // The 'internalname' attribute of this font, or + // a null pointer. Used by get_internal_name(). + double slant; // The natural slant angle (in degrees) of this font. + int zoom; // The font's magnification, multiplied by 1000. + // Used by scale(). A zero value means 'no zoom'. + int *ch_index; // Conversion table from font-independent character + // indices to indices for this particular font. + int nindices; + font_char_metric *ch; // Metrics information for every character in this + // font (if !is_unicode) or for just some characters + // (if is_unicode). The indices of this array are + // font-specific, found as values in ch_index[]. + int ch_used; + int ch_size; + font_widths_cache *widths_cache; // A cache of scaled character + // widths. Used by the get_width() function. + + static FONT_COMMAND_HANDLER unknown_desc_command_handler; // A + // function defining the semantics of arbitrary + // commands in the DESC file. + enum { KERN_HASH_TABLE_SIZE = 503 }; // Size of the hash table of kerning + // pairs. + + // These methods add new characters to the ch_index[] and ch[] arrays. + void add_entry(glyph *, // glyph + const font_char_metric &); // metric + void copy_entry(glyph *, // new_glyph + glyph *); // old_glyph + void alloc_ch_index(int); // index + void extend_ch(); + void compact(); + + void add_kern(glyph *, glyph *, int); // Add to the kerning table a + // kerning amount (arg3) between two given glyphs + // (arg1 and arg2). + static int hash_kern(glyph *, glyph *); // Return a hash code for + // the pair of glyphs (arg1 and arg2). + + /* Returns w * pointsize / unitwidth, rounded to the nearest integer. */ + int scale(int w, int pointsize); + static bool unit_scale(double *, char); // Convert value in arg1 from + // the given unit (arg2; possible values are + // 'i', 'c', 'p', and 'P' as documented in the + // info file of groff, section 'Measurements') + // to inches. Store result in arg1 and return + // whether conversion was successful. + virtual void handle_unknown_font_command(const char *, // command + const char *, // arg + const char *, // file + int); // lineno + +protected: + font(const char *); // Initialize a font with the given name. + + // Load the font description file with the name in member variable + // `name` into this object. If arg1 is true, only the part of the + // font description file before the 'charset' and 'kernpairs' sections + // is loaded. Return success/failure status of load. + bool load(bool = false); +}; + +// Local Variables: +// fill-column: 72 +// mode: C++ +// End: +// vim: set cindent noexpandtab shiftwidth=2 textwidth=72: diff --git a/src/include/geometry.h b/src/include/geometry.h new file mode 100644 index 0000000..9f87f1b --- /dev/null +++ b/src/include/geometry.h @@ -0,0 +1,26 @@ +// -*- C++ -*- +/* Copyright (C) 2001-2020 Free Software Foundation, Inc. + Written by Gaius Mulley + +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 3 of the License, 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 this program. If not, see . */ + +int adjust_arc_center(const int *, double *); +void check_output_arc_limits(int x, int y, + int xv1, int yv1, + int xv2, int yv2, + double c0, double c1, + int *minx, int *maxx, + int *miny, int *maxy); diff --git a/src/include/getopt.h b/src/include/getopt.h new file mode 100644 index 0000000..3d81e6d --- /dev/null +++ b/src/include/getopt.h @@ -0,0 +1,226 @@ +/* Declarations for getopt. + Copyright (C) 1989-2020 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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 this program. If not, see . */ + +#ifndef _GETOPT_H + +#ifndef __need_getopt +# define _GETOPT_H 1 +#endif + +/* Standalone applications should #define __GETOPT_PREFIX to an + identifier that prefixes the external functions and variables + defined in this header. When this happens, include the + headers that might declare getopt so that they will not cause + confusion if included after this file. Then systematically rename + identifiers so that they do not collide with the system functions + and variables. Renaming avoids problems with some compilers and + linkers. */ +#if defined __GETOPT_PREFIX && !defined __need_getopt +# include +# include +# if HAVE_UNISTD_H +# include +# endif +# undef __need_getopt +# undef getopt +# undef getopt_long +# undef getopt_long_only +# undef optarg +# undef opterr +# undef optind +# undef optopt +# define __GETOPT_CONCAT(x, y) x ## y +# define __GETOPT_XCONCAT(x, y) __GETOPT_CONCAT (x, y) +# define __GETOPT_ID(y) __GETOPT_XCONCAT (__GETOPT_PREFIX, y) +# define getopt __GETOPT_ID (getopt) +# define getopt_long __GETOPT_ID (getopt_long) +# define getopt_long_only __GETOPT_ID (getopt_long_only) +# define optarg __GETOPT_ID (optarg) +# define opterr __GETOPT_ID (opterr) +# define optind __GETOPT_ID (optind) +# define optopt __GETOPT_ID (optopt) +#endif + +/* Standalone applications get correct prototypes for getopt_long and + getopt_long_only; they declare "char **argv". libc uses prototypes + with "char *const *argv" that are incorrect because getopt_long and + getopt_long_only can permute argv; this is required for backward + compatibility (e.g., for LSB 2.0.1). + + This used to be '#if defined __GETOPT_PREFIX && !defined __need_getopt', + but it caused redefinition warnings if both unistd.h and getopt.h were + included, since unistd.h includes getopt.h having previously defined + __need_getopt. + + The only place where __getopt_argv_const is used is in definitions + of getopt_long and getopt_long_only below, but these are visible + only if __need_getopt is not defined, so it is quite safe to rewrite + the conditional as follows: +*/ +#if !defined __need_getopt +# if defined __GETOPT_PREFIX +# define __getopt_argv_const /* empty */ +# else +# define __getopt_argv_const const +# endif +#endif + +/* If __GNU_LIBRARY__ is not already defined, either we are being used + standalone, or this is the first header included in the source file. + If we are being used with glibc, we need to include , but + that does not exist if we are standalone. So: if __GNU_LIBRARY__ is + not defined, include , which will pull in for us + if it's from glibc. (Why ctype.h? It's guaranteed to exist and it + doesn't flood the namespace with stuff the way some other headers do.) */ +#if !defined __GNU_LIBRARY__ +# include +#endif + +#ifndef __THROW +# ifndef __GNUC_PREREQ +# define __GNUC_PREREQ(maj, min) (0) +# endif +# if defined __cplusplus && __GNUC_PREREQ (2,8) +# define __THROW throw () +# else +# define __THROW +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* For communication from 'getopt' to the caller. + When 'getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when 'ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to 'getopt'. + + On entry to 'getopt', zero means this is the first call; initialize. + + When 'getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, 'optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message 'getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Set to an option character which was unrecognized. */ + +extern int optopt; + +#ifndef __need_getopt +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of 'struct option' terminated by an element containing a name which is + zero. + + The field 'has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field 'flag' is not NULL, it points to a variable that is set + to the value given in the field 'val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an 'int' to + a compiled-in constant, such as set a value from 'optarg', set the + option's 'flag' field to zero and its 'val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero 'flag' field, 'getopt' + returns the contents of the 'val' field. */ + +struct option +{ + const char *name; + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the 'has_arg' field of 'struct option'. */ + +# define no_argument 0 +# define required_argument 1 +# define optional_argument 2 +#endif /* need getopt */ + + +/* Get definitions and prototypes for functions to process the + arguments in ARGV (ARGC of them, minus the program name) for + options given in OPTS. + + Return the option character from OPTS just read. Return -1 when + there are no more options. For unrecognized options, or options + missing arguments, 'optopt' is set to the option letter, and '?' is + returned. + + The OPTS string is a list of characters which are recognized option + letters, optionally followed by colons, specifying that that letter + takes an argument, to be placed in 'optarg'. + + If a letter in OPTS is followed by two colons, its argument is + optional. This behavior is specific to the GNU 'getopt'. + + The argument '--' causes premature termination of argument + scanning, explicitly telling 'getopt' that there are no more + options. + + If OPTS begins with '--', then non-option arguments are treated as + arguments to the option '\0'. This behavior is specific to the GNU + 'getopt'. */ + +extern int getopt (int ___argc, char *const *___argv, const char *__shortopts) + __THROW; + +#ifndef __need_getopt +extern int getopt_long (int ___argc, char *__getopt_argv_const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW; +extern int getopt_long_only (int ___argc, char *__getopt_argv_const *___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind) + __THROW; + +#endif + +#ifdef __cplusplus +} +#endif + +/* Make sure we later can get all the definitions and declarations. */ +#undef __need_getopt + +#endif /* getopt.h */ diff --git a/src/include/getopt_int.h b/src/include/getopt_int.h new file mode 100644 index 0000000..fa6be44 --- /dev/null +++ b/src/include/getopt_int.h @@ -0,0 +1,130 @@ +/* Internal declarations for getopt. + Copyright (C) 1989-2020 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + This program 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 3 of the License, or + (at your option) any later version. + + This program 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 this program. If not, see . */ + +#ifndef _GETOPT_INT_H +#define _GETOPT_INT_H 1 + +extern int _getopt_internal (int ___argc, char **___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, int __posixly_correct); + + +/* Reentrant versions which can handle parsing multiple argument + vectors at the same time. */ + +/* Data type for reentrant functions. */ +struct _getopt_data +{ + /* These have exactly the same meaning as the corresponding global + variables, except that they are used for the reentrant + versions of getopt. */ + int optind; + int opterr; + int optopt; + char *optarg; + + /* Internal members. */ + + /* True if the internal members have been initialized. */ + int __initialized; + + /* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + char *__nextchar; + + /* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using '+' as the first character + of the list of option characters, or by calling getopt. + + PERMUTE is the default. We permute the contents of ARGV as we + scan, so that eventually all the non-options are at the end. + This allows options to be given in any order, even with programs + that were not written to expect this. + + RETURN_IN_ORDER is an option available to programs that were + written to expect options and other ARGV-elements in any order + and that care about the ordering of the two. We describe each + non-option ARGV-element as if it were the argument of an option + with character code 1. Using '-' as the first character of the + list of option characters selects this mode of operation. + + The special argument '--' forces an end of option-scanning regardless + of the value of 'ordering'. In the case of RETURN_IN_ORDER, only + '--' can cause 'getopt' to return -1 with 'optind' != ARGC. */ + + enum + { + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER + } __ordering; + + /* If the POSIXLY_CORRECT environment variable is set + or getopt was called. */ + int __posixly_correct; + + + /* Handle permutation of arguments. */ + + /* Describe the part of ARGV that contains non-options that have + been skipped. 'first_nonopt' is the index in ARGV of the first + of them; 'last_nonopt' is the index after the last of them. */ + + int __first_nonopt; + int __last_nonopt; + +#if defined _LIBC && defined USE_NONOPTION_FLAGS + int __nonoption_flags_max_len; + int __nonoption_flags_len; +# endif +}; + +/* The initializer is necessary to set OPTIND and OPTERR to their + default values and to clear the initialization flag. */ +#define _GETOPT_DATA_INITIALIZER { 1, 1 } + +extern int _getopt_internal_r (int ___argc, char **___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + int __long_only, int __posixly_correct, + struct _getopt_data *__data); + +extern int _getopt_long_r (int ___argc, char **___argv, + const char *__shortopts, + const struct option *__longopts, int *__longind, + struct _getopt_data *__data); + +extern int _getopt_long_only_r (int ___argc, char **___argv, + const char *__shortopts, + const struct option *__longopts, + int *__longind, + struct _getopt_data *__data); + +#endif /* getopt_int.h */ diff --git a/src/include/gettext.h b/src/include/gettext.h new file mode 100644 index 0000000..8a22212 --- /dev/null +++ b/src/include/gettext.h @@ -0,0 +1,22 @@ +/* -*- C -*- */ +/* Copyright (C) 2014-2020 Free Software Foundation, Inc. + +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 3 of the License, 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 this program. If not, see . */ + +/* This is a dummy header file to make getopt compile without gettext + support. */ + +#define gettext(s) s diff --git a/src/include/html-strings.h b/src/include/html-strings.h new file mode 100644 index 0000000..eaf551b --- /dev/null +++ b/src/include/html-strings.h @@ -0,0 +1,26 @@ +// -*- C++ -*- +/* Copyright (C) 2001-2020 Free Software Foundation, Inc. + Written by Gaius Mulley (gaius@glam.ac.uk). + +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 3 of the License, 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 this program. If not, see . */ + +/* + * defines the image tags issued by the pre-processors (tbl, pic, eqn) + * and later detected by pre-html.cpp + */ + +#define HTML_IMAGE_INLINE_BEGIN "\\O[HTML-IMAGE-INLINE-BEGIN]" +#define HTML_IMAGE_INLINE_END "\\O[HTML-IMAGE-INLINE-END]" diff --git a/src/include/htmlhint.h b/src/include/htmlhint.h new file mode 100644 index 0000000..c12a8b9 --- /dev/null +++ b/src/include/htmlhint.h @@ -0,0 +1,36 @@ +// -*- C++ -*- +/* Copyright (C) 2000-2020 Free Software Foundation, Inc. + Written by Gaius Mulley + +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 3 of the License, 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 this program. If not, see . */ + +#ifndef HTMLINDICATE_H +#define HTMLINDICATE_H + +/* + * html_begin_suppress - suppresses output for the html device + * and resets the min/max registers for -Tps. + * Only called for inline images (such as eqn). + * + */ +extern void html_begin_suppress(); + +/* + * html_end_suppress - end the suppression of output. + */ +extern void html_end_suppress(); + +#endif diff --git a/src/include/include.am b/src/include/include.am new file mode 100644 index 0000000..ca32d6d --- /dev/null +++ b/src/include/include.am @@ -0,0 +1,47 @@ +# Automake rules for 'include' +# +# Copyright (C) 2014-2020 Free Software Foundation, Inc. +# +# '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 of the License, 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 this program. If not, see +# . +# +######################################################################## + +nodist_noinst_HEADERS = defs.h +CLEANFILES += defs.h +defs.h: config.status + @$(SHELL) $(top_srcdir)/gendef.sh defs.h \ + "PROG_PREFIX=\"$(g)\"" \ + "DEVICE=\"$(DEVICE)\"" \ + "INSTALLPATH=\"$(prefix)\"" \ + "BINPATH=\"$(bindir)\"" \ + "FONTPATH=\"$(fontpath)\"" \ + "MACROPATH=\"$(tmacpath)\"" \ + "INDEX_SUFFIX=\"$(indexext)\"" \ + "COMMON_WORDS_FILE=\"$(common_words_file)\"" \ + "DEFAULT_INDEX_DIR=\"$(indexdir)\"" \ + "DEFAULT_INDEX_NAME=\"$(indexname)\"" \ + "DEFAULT_INDEX=\"$(indexdir)/$(indexname)\"" + +dist-hook: dist_include +dist_include: + chmod u+w $(distdir)/src/include + cp -f $(top_srcdir)/src/include/*.h $(distdir)/src/include + + +# Local Variables: +# mode: makefile-automake +# fill-column: 72 +# End: +# vim: set autoindent filetype=automake textwidth=72: diff --git a/src/include/index.h b/src/include/index.h new file mode 100644 index 0000000..a7d3201 --- /dev/null +++ b/src/include/index.h @@ -0,0 +1,41 @@ +// -*- C++ -*- +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +#define INDEX_MAGIC 0x23021964 +#define INDEX_VERSION 1 + +struct index_header { + int magic; + int version; + int tags_size; + int table_size; + int lists_size; + int strings_size; + int truncate; + int shortest; + int common; +}; + +struct tag { + int filename_index; + int start; + int length; +}; + +unsigned hash(const char *s, int len); diff --git a/src/include/itable.h b/src/include/itable.h new file mode 100644 index 0000000..c97db55 --- /dev/null +++ b/src/include/itable.h @@ -0,0 +1,193 @@ +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +#include + +// 'class ITABLE(T)' is the type of a hash table mapping an integer (int >= 0) +// to an object of type T. +// +// 'struct IASSOC(T)' is the type of a association (pair) between an integer +// (int >= 0) and an object of type T. +// +// 'class ITABLE_ITERATOR(T)' is the type of an iterator iterating through a +// 'class ITABLE(T)'. +// +// Nowadays one would use templates for this; this code predates the addition +// of templates to C++. +#define ITABLE(T) T ## _itable +#define IASSOC(T) T ## _iassoc +#define ITABLE_ITERATOR(T) T ## _itable_iterator + +// ptable.h declares this too +#ifndef NEXT_PTABLE_SIZE_DEFINED +# define NEXT_PTABLE_SIZE_DEFINED +extern unsigned next_ptable_size(unsigned); // Return the first suitable + // hash table size greater than the given + // value. +#endif + +// Declare the types 'class ITABLE(T)', 'struct IASSOC(T)', and 'class +// ITABLE_ITERATOR(T)' for the type 'T'. +#define declare_itable(T) \ + \ +struct IASSOC(T) { \ + int key; \ + T *val; \ + IASSOC(T)(); \ +}; \ + \ +class ITABLE(T); \ + \ +class ITABLE_ITERATOR(T) { \ + ITABLE(T) *p; \ + unsigned i; \ +public: \ + ITABLE_ITERATOR(T)(ITABLE(T) *); /* Initialize an iterator running \ + through the given table. */ \ + int next(int *, T **); /* Fetch the next pair, store the key \ + and value in arg1 and arg2, \ + respectively, and return 1. If \ + there is no more pair in the \ + table, return 0. */ \ +}; \ + \ +class ITABLE(T) { \ + IASSOC(T) *v; \ + unsigned size; \ + unsigned used; \ + enum { \ + FULL_NUM = 2, \ + FULL_DEN = 3, \ + INITIAL_SIZE = 17 \ + }; \ +public: \ + ITABLE(T)(); /* Create an empty table. */ \ + ~ITABLE(T)(); /* Delete a table, including its \ + values. */ \ + void define(int, T *); /* Define the value (arg2) for a key \ + (arg1). */ \ + T *lookup(int); /* Return a pointer to the value of \ + the given key, if found in the \ + table, or NULL otherwise. */ \ + friend class ITABLE_ITERATOR(T); \ +}; + + +// Values must be allocated by the caller (always using new[], not new) +// and are freed by ITABLE. + +// Define the implementations of the members of the types 'class ITABLE(T)', +// 'struct IASSOC(T)', 'class ITABLE_ITERATOR(T)' for the type 'T'. +#define implement_itable(T) \ + \ +IASSOC(T)::IASSOC(T)() \ +: key(-1), val(0) \ +{ \ +} \ + \ +ITABLE(T)::ITABLE(T)() \ +{ \ + v = new IASSOC(T)[size = INITIAL_SIZE]; \ + used = 0; \ +} \ + \ +ITABLE(T)::~ITABLE(T)() \ +{ \ + for (unsigned i = 0; i < size; i++) \ + delete[] v[i].val; \ + delete[] v; \ +} \ + \ +void ITABLE(T)::define(int key, T *val) \ +{ \ + assert(key >= 0); \ + unsigned int h = (unsigned int)(key); \ + unsigned n; \ + for (n = unsigned(h % size); \ + v[n].key >= 0; \ + n = (n == 0 ? size - 1 : n - 1)) \ + if (v[n].key == key) { \ + delete[] v[n].val; \ + v[n].val = val; \ + return; \ + } \ + if (val == 0) \ + return; \ + if (used*FULL_DEN >= size*FULL_NUM) { \ + IASSOC(T) *oldv = v; \ + unsigned old_size = size; \ + size = next_ptable_size(size); \ + v = new IASSOC(T)[size]; \ + for (unsigned i = 0; i < old_size; i++) \ + if (oldv[i].key >= 0) { \ + if (oldv[i].val != 0) { \ + unsigned j; \ + for (j = (unsigned int)(oldv[i].key) % size; \ + v[j].key >= 0; \ + j = (j == 0 ? size - 1 : j - 1)) \ + ; \ + v[j].key = oldv[i].key; \ + v[j].val = oldv[i].val; \ + } \ + } \ + for (n = unsigned(h % size); \ + v[n].key >= 0; \ + n = (n == 0 ? size - 1 : n - 1)) \ + ; \ + delete[] oldv; \ + } \ + v[n].key = key; \ + v[n].val = val; \ + used++; \ +} \ + \ +T *ITABLE(T)::lookup(int key) \ +{ \ + assert(key >= 0); \ + for (unsigned n = (unsigned int)key % size; \ + v[n].key >= 0; \ + n = (n == 0 ? size - 1 : n - 1)) \ + if (v[n].key == key) \ + return v[n].val; \ + return 0; \ +} \ + \ +ITABLE_ITERATOR(T)::ITABLE_ITERATOR(T)(ITABLE(T) *t) \ +: p(t), i(0) \ +{ \ +} \ + \ +int ITABLE_ITERATOR(T)::next(int *keyp, T **valp) \ +{ \ + unsigned size = p->size; \ + IASSOC(T) *v = p->v; \ + for (; i < size; i++) \ + if (v[i].key >= 0) { \ + *keyp = v[i].key; \ + *valp = v[i].val; \ + i++; \ + return 1; \ + } \ + return 0; \ +} + +// Local Variables: +// fill-column: 72 +// mode: C++ +// End: +// vim: set cindent noexpandtab shiftwidth=2 textwidth=72: diff --git a/src/include/lf.h b/src/include/lf.h new file mode 100644 index 0000000..dc85a84 --- /dev/null +++ b/src/include/lf.h @@ -0,0 +1,21 @@ +// -*- C++ -*- +/* Copyright (C) 2014-2020 Free Software Foundation, Inc. + Written by Werner Lemberg (wl@gnu.org) + +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 3 of the License, 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 this program. If not, see . */ + +int interpret_lf_args(const char *p); +void normalize_for_lf (string &fn); diff --git a/src/include/lib.h b/src/include/lib.h new file mode 100644 index 0000000..6b1d854 --- /dev/null +++ b/src/include/lib.h @@ -0,0 +1,161 @@ +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +#ifndef GROFF_LIB_H +#define GROFF_LIB_H + +#ifdef HAVE_CONFIG_H +#include +#endif + +#if defined(__INTERIX) && !defined(_ALL_SOURCE) +#define _ALL_SOURCE +#endif + +#ifdef __cplusplus +extern "C" { +#endif +#ifndef HAVE_STRERROR + char *strerror(int); +#endif + const char *i_to_a(int); + const char *ui_to_a(unsigned int); + const char *if_to_a(int, int); +#ifdef __cplusplus +} +#endif + +#define __GETOPT_PREFIX groff_ +#include + +#ifdef HAVE_SETLOCALE +#include +#define getlocale(category) setlocale(category, NULL) +#else /* !HAVE_SETLOCALE */ +#define LC_ALL 0 +#define LC_CTYPE 0 +#define setlocale(category, locale) (void)(category, locale) +#define getlocale(category) ((void)(category), (char *)"C") +#endif /* !HAVE_SETLOCALE */ + +#include + +char *strsave(const char *s); +bool is_prime(unsigned); +double groff_hypot(double, double); + +#include +#include +#ifdef HAVE_STRINGS_H +#include +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* LynxOS 4.0.0 doesn't declare vfprintf() */ +#ifdef NEED_DECLARATION_VFPRINTF + int vfprintf(FILE *, const char *, va_list); +#endif + +#ifndef HAVE_MKSTEMP +/* since mkstemp() is defined as a real C++ function if taken from + groff's mkstemp.cpp we need a declaration */ +int mkstemp(char *tmpl); +#endif /* HAVE_MKSTEMP */ + +int mksdir(char *tmpl); + +#ifdef __cplusplus + FILE *xtmpfile(char **namep = 0, + const char *postfix_long = 0, + const char *postfix_short = 0, + int do_unlink = 1); + char *xtmptemplate(const char *postfix_long, + const char *postfix_short); +#endif + +#ifdef NEED_DECLARATION_POPEN + FILE *popen(const char *, const char *); +#endif /* NEED_DECLARATION_POPEN */ + +#ifdef NEED_DECLARATION_PCLOSE + int pclose (FILE *); +#endif /* NEED_DECLARATION_PCLOSE */ + + size_t file_name_max(const char *fname); + size_t path_name_max(void); + + extern char invalid_char_table[]; + + inline bool is_invalid_input_char(int c) + { + return (c >= 0 && invalid_char_table[c]); + } + +#ifdef HAVE_STRCASECMP +#ifdef NEED_DECLARATION_STRCASECMP +// Ultrix4.3's string.h fails to declare this. + int strcasecmp(const char *, const char *); } +#endif /* NEED_DECLARATION_STRCASECMP */ +#else /* !HAVE_STRCASECMP */ + int strcasecmp(const char *, const char *); +#endif /* HAVE_STRCASECMP */ + +#if !defined(_AIX) && !defined(sinix) && !defined(__sinix__) +#ifdef HAVE_STRNCASECMP +#ifdef NEED_DECLARATION_STRNCASECMP +// SunOS's string.h fails to declare this. + int strncasecmp(const char *, const char *, int); +#endif /* NEED_DECLARATION_STRNCASECMP */ +#else /* !HAVE_STRNCASECMP */ + int strncasecmp(const char *, const char *, size_t); +#endif /* HAVE_STRNCASECMP */ +#endif /* !_AIX && !sinix && !__sinix__ */ + +#ifdef __cplusplus +} +#endif + +#ifdef HAVE_CC_LIMITS_H +#include +#else /* !HAVE_CC_LIMITS_H */ +#define INT_MAX 2147483647 +#endif /* !HAVE_CC_LIMITS_H */ + +/* Maximum number of digits in decimal representations of `int` types + not including a leading minus sign. */ +#define INT_DIGITS 19 /* enough for 64 bit integer */ +#define UINT_DIGITS 20 + +#ifdef PI +#undef PI +#endif + +static const double PI = 3.14159265358979323846; + +#endif /* GROFF_LIB_H */ + +// Local Variables: +// fill-column: 72 +// mode: C++ +// End: +// vim: set cindent noexpandtab shiftwidth=2 textwidth=72: diff --git a/src/include/localcharset.h b/src/include/localcharset.h new file mode 100644 index 0000000..bbf694e --- /dev/null +++ b/src/include/localcharset.h @@ -0,0 +1,40 @@ +/* Determine a canonical name for the current locale's character encoding. + Copyright (C) 2000-2020 Free Software Foundation, Inc. + This file is part of the GNU CHARSET Library. + + This program 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. + + This program 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 this program; if not, see . */ + +#ifndef _LOCALCHARSET_H +#define _LOCALCHARSET_H + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Determine the current locale's character encoding, and canonicalize it + into one of the canonical names listed in config.charset. + The result must not be freed; it is statically allocated. + If the canonical name cannot be determined, the result is a non-canonical + name. */ +extern const char * locale_charset (void); + + +#ifdef __cplusplus +} +#endif + + +#endif /* _LOCALCHARSET_H */ diff --git a/src/include/macropath.h b/src/include/macropath.h new file mode 100644 index 0000000..26c1baf --- /dev/null +++ b/src/include/macropath.h @@ -0,0 +1,22 @@ +// -*- C++ -*- +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +extern search_path macro_path; +extern search_path safer_macro_path; +extern search_path config_macro_path; diff --git a/src/include/nonposix.h b/src/include/nonposix.h new file mode 100644 index 0000000..6a61009 --- /dev/null +++ b/src/include/nonposix.h @@ -0,0 +1,230 @@ +/* -*- C -*- */ +/* Copyright (C) 2000-2020 Free Software Foundation, Inc. + Written by Eli Zaretskii (eliz@is.elta.co.il) + +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 3 of the License, 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 this program. If not, see . */ + +/* This header file compartmentalize all idiosyncrasies of non-Posix + systems, such as MS-DOS, MS-Windows, etc. It should be loaded after + the system headers like stdio.h to protect against warnings and error + messages w.r.t. redefining macros. */ + +#if defined _MSC_VER +# ifndef _WIN32 +# define _WIN32 +# endif +#endif + +#if defined(__MSDOS__) || defined(__EMX__) \ + || (defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__)) + +/* Binary I/O nuisances. */ +# include +# include +# ifdef HAVE_UNISTD_H +# include +# endif +# ifndef STDIN_FILENO +# define STDIN_FILENO 0 +# define STDOUT_FILENO 1 +# define STDERR_FILENO 2 +# endif +# ifdef HAVE_DIRECT_H +# include +# endif +# ifdef HAVE_PROCESS_H +# include +# endif +# if defined(_MSC_VER) || defined(__MINGW32__) +# define POPEN_RT "rt" +# define POPEN_WT "wt" +# define popen(c,m) _popen(c,m) +# define pclose(p) _pclose(p) +# define pipe(pfd) _pipe((pfd),0,_O_BINARY|_O_NOINHERIT) +# define mkdir(p,m) _mkdir(p) +# define setmode(f,m) _setmode(f,m) +# define WAIT(s,p,m) _cwait(s,p,m) +# define creat(p,m) _creat(p,m) +# define read(f,b,s) _read(f,b,s) +# define write(f,b,s) _write(f,b,s) +# define dup(f) _dup(f) +# define dup2(f1,f2) _dup2(f1,f2) +# define close(f) _close(f) +# define isatty(f) _isatty(f) +# define access(p,m) _access(p,m) +# endif +# define SET_BINARY(f) do {if (!isatty(f)) setmode(f,O_BINARY);} while(0) +# define FOPEN_RB "rb" +# define FOPEN_WB "wb" +# define FOPEN_RWB "wb+" +# ifndef O_BINARY +# ifdef _O_BINARY +# define O_BINARY (_O_BINARY) +# endif +# endif + +/* The system shell. Groff assumes a Unixy shell, but non-Posix + systems don't have standard places where it lives, and might not + have it installed to begin with. We want to give them some leeway. */ +# ifdef __EMX__ +# define getcwd(b,s) _getcwd2(b,s) +# else +# define BSHELL (system_shell_name()) +# define BSHELL_DASH_C (system_shell_dash_c()) +# define IS_BSHELL(s) (is_system_shell(s)) +# endif + +/* The separator for directories in PATH and other environment + variables. */ +# define PATH_SEP ";" +# define PATH_SEP_CHAR ';' + +/* Characters that separate directories in a path name. */ +# define DIR_SEPS "/\\:" + +/* How to tell if the argument is an absolute file name. */ +# define IS_ABSOLUTE(f) \ + ((f)[0] == '/' || (f)[0] == '\\' || (f)[0] && (f)[1] == ':') + +/* The executable extension. */ +# define EXE_EXT ".exe" + +/* Possible executable extensions. */ +# define PATH_EXT ".com;.exe;.bat;.cmd" + +/* The system null device. */ +# define NULL_DEV "NUL" + +/* The default place to create temporary files. */ +# ifndef P_tmpdir +# ifdef _P_tmpdir +# define P_tmpdir _P_tmpdir +# else +# define P_tmpdir "c:/temp" +# endif +# endif + +/* Prototypes. */ +# ifdef __cplusplus + extern "C" { +# endif + char * system_shell_name(void); + const char * system_shell_dash_c(void); + int is_system_shell(const char *); +# ifdef __cplusplus + } +# endif + +#endif + +#if defined(_WIN32) && !defined(_UWIN) && !defined(__CYGWIN__) +/* Win32 implementations which use the Microsoft runtime library + * are prone to hanging when a pipe reader quits with unread data in the pipe. + * 'gtroff' avoids this, by invoking 'FLUSH_INPUT_PIPE()', defined as ... */ +# define FLUSH_INPUT_PIPE(fd) \ + do if (!isatty(fd)) \ + { \ + char drain[BUFSIZ]; \ + while (read(fd, drain, sizeof(drain)) > 0) \ + ; \ + } while (0) + +/* The Microsoft runtime library also has a broken argument passing mechanism, + * which may result in improper grouping of arguments passed to a child process + * by the 'spawn()' family of functions. In 'groff', only the 'spawnvp()' + * function is affected; we work around this defect, by substituting a + * wrapper function in place of 'spawnvp()' calls. */ + +# ifdef __cplusplus + extern "C" { +# endif + int spawnvp_wrapper(int, char *, char **); +# ifdef __cplusplus + } +# endif +# ifndef SPAWN_FUNCTION_WRAPPERS +# undef spawnvp +# define spawnvp spawnvp_wrapper +# undef _spawnvp +# define _spawnvp spawnvp +# endif /* SPAWN_FUNCTION_WRAPPERS */ + +#else +/* Other implementations do not suffer from Microsoft runtime bugs, + * but 'gtroff' requires a dummy definition for FLUSH_INPUT_PIPE() */ +# define FLUSH_INPUT_PIPE(fd) do {} while(0) +#endif + +/* Defaults, for Posix systems. */ + +#ifndef SET_BINARY +# define SET_BINARY(f) do {} while(0) +#endif +#ifndef FOPEN_RB +# define FOPEN_RB "r" +#endif +#ifndef FOPEN_WB +# define FOPEN_WB "w" +#endif +#ifndef FOPEN_RWB +# define FOPEN_RWB "w+" +#endif +#ifndef POPEN_RT +# define POPEN_RT "r" +#endif +#ifndef POPEN_WT +# define POPEN_WT "w" +#endif +#ifndef O_BINARY +# define O_BINARY 0 +#endif +#ifndef BSHELL +# define BSHELL "/bin/sh" +#endif +#ifndef BSHELL_DASH_C +# define BSHELL_DASH_C "-c" +#endif +#ifndef IS_BSHELL +# define IS_BSHELL(s) ((s) && strcmp(s,BSHELL) == 0) +#endif +#ifndef PATH_SEP +# define PATH_SEP ":" +# define PATH_SEP_CHAR ':' +#endif +#ifndef DIR_SEPS +# define DIR_SEPS "/" +#endif +#ifndef IS_ABSOLUTE +# define IS_ABSOLUTE(f) ((f)[0] == '/') +#endif +#ifndef EXE_EXT +# define EXE_EXT "" +#endif +#ifndef PATH_EXT +# define PATH_EXT "" +#endif +#ifndef NULL_DEV +# define NULL_DEV "/dev/null" +#endif +#ifndef GS_NAME +# define GS_NAME "gs" +#endif +#ifndef WAIT +# define WAIT(s,p,m) wait(s) +#endif +#ifndef _WAIT_CHILD +# define _WAIT_CHILD 0 +#endif diff --git a/src/include/paper.h b/src/include/paper.h new file mode 100644 index 0000000..ed789c4 --- /dev/null +++ b/src/include/paper.h @@ -0,0 +1,36 @@ +// -*- C++ -*- +/* Copyright (C) 2002-2020 Free Software Foundation, Inc. + Written by Werner Lemberg (wl@gnu.org) + +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 3 of the License, 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 this program. If not, see . */ + +struct paper { + char *name; + double length; // in PS points + double width; // in PS points +}; + +// global constructor +static class papersize_init { + static int initialised; +public: + papersize_init(); +} _papersize_init; + +// A0-A7, B0-B7, C0-C7, D0-D7, 8 American paper sizes, 1 special size */ +#define NUM_PAPERSIZES 4*8 + 8 + 1 + +extern paper papersizes[]; diff --git a/src/include/posix.h b/src/include/posix.h new file mode 100644 index 0000000..81c2d22 --- /dev/null +++ b/src/include/posix.h @@ -0,0 +1,66 @@ +// -*- C++ -*- +/* Copyright (C) 1992-2020 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 3 of the License, 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 this program. If not, see . */ + +#include +#include + +#ifdef HAVE_CC_OSFCN_H +#include +#else +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#endif + +#ifndef S_IRUSR +#define S_IRUSR 0400 +#endif + +#ifndef S_IRGRP +#define S_IRGRP 0040 +#endif + +#ifndef S_IROTH +#define S_IROTH 0004 +#endif + +#ifndef S_IWUSR +#define S_IWUSR 0200 +#endif + +#ifndef S_IXUSR +#define S_IXUSR 0100 +#endif + +#ifndef S_ISREG +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif + +#ifndef O_RDONLY +#define O_RDONLY 0 +#endif + +#ifndef F_OK +#define F_OK 0 +#endif + +#ifndef HAVE_ISATTY +#define isatty(n) (1) +#endif diff --git a/src/include/printer.h b/src/include/printer.h new file mode 100644 index 0000000..7b6a7ba --- /dev/null +++ b/src/include/printer.h @@ -0,0 +1,97 @@ +// -*- C++ -*- + +// /src/include/printer.h + +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . +*/ + +/* Description + + The class 'printer' performs the postprocessing. Each + postprocessor only needs to implement a derived class of 'printer' and + a suitable function 'make_printer' for the device-dependent tasks. + Then the methods of class 'printer' are called automatically by + 'do_file()' in 'input.cpp'. +*/ + +#include "color.h" + +struct environment { + int fontno; + int size; + int hpos; + int vpos; + int height; + int slant; + color *col; + color *fill; +}; + +class font; + +struct font_pointer_list { + font *p; + font_pointer_list *next; + + font_pointer_list(font *, font_pointer_list *); +}; + +class printer { +public: + printer(); + virtual ~printer(); + void load_font(int, const char *); + void set_ascii_char(unsigned char, const environment *, int * = 0); + void set_special_char(const char *, const environment *, int * = 0); + virtual void set_numbered_char(int, const environment *, int * = 0); + glyph *set_char_and_width(const char *, const environment *, + int *, font **); + font *get_font_from_index(int); + virtual void draw(int, int *, int, const environment *); + // perform change of line color (text, outline) in the print-out + virtual void change_color(const environment * const); + // perform change of fill color in the print-out + virtual void change_fill_color(const environment * const); + virtual void begin_page(int) = 0; + virtual void end_page(int) = 0; + virtual font *make_font(const char *); + virtual void end_of_line(); + virtual void special(char *, const environment *, char = 'p'); + virtual void devtag(char *, const environment *, char = 'p'); + +protected: + font_pointer_list *font_list; + font **font_table; + int nfonts; + + // information about named characters + int is_char_named; + int is_named_set; + char named_command; + const char *named_char_s; + int named_char_n; + +private: + font *find_font(const char *); + virtual void set_char(glyph *, font *, const environment *, int, + const char *) = 0; +}; + +printer *make_printer(); diff --git a/src/include/ptable.h b/src/include/ptable.h new file mode 100644 index 0000000..fa79293 --- /dev/null +++ b/src/include/ptable.h @@ -0,0 +1,233 @@ +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +#include +#include + +// 'class PTABLE(T)' is the type of a hash table mapping a string +// (const char *) to an object of type T. +// +// 'struct PASSOC(T)' is the type of a association (pair) between a +// string (const char *) and an object of type T. +// +// 'class PTABLE_ITERATOR(T)' is the type of an iterator iterating through a +// 'class PTABLE(T)'. +// +// Nowadays one would use templates for this; this code predates the addition +// of templates to C++. +#define PTABLE(T) T ## _ptable +#define PASSOC(T) T ## _passoc +#define PTABLE_ITERATOR(T) T ## _ptable_iterator + +// itable.h declares this too +#ifndef NEXT_PTABLE_SIZE_DEFINED +# define NEXT_PTABLE_SIZE_DEFINED +extern unsigned next_ptable_size(unsigned); // Return the first suitable + // hash table size greater than the given + // value. +#endif + +extern unsigned long hash_string(const char *); // Return a hash code of the + // given string. The hash function is + // platform dependent. */ + +// Declare the types 'class PTABLE(T)', 'struct PASSOC(T)', and 'class +// PTABLE_ITERATOR(T)' for the type 'T'. +#define declare_ptable(T) \ + \ +struct PASSOC(T) { \ + char *key; \ + T *val; \ + PASSOC(T)(); \ +}; \ + \ +class PTABLE(T); \ + \ +class PTABLE_ITERATOR(T) { \ + PTABLE(T) *p; \ + unsigned i; \ +public: \ + PTABLE_ITERATOR(T)(PTABLE(T) *); /* Initialize an iterator running \ + through the given table. */ \ + int next(const char **, T **); /* Fetch the next pair, store the key \ + and value in arg1 and arg2, \ + respectively, and return 1. If \ + there is no more pair in the \ + table, return 0. */ \ +}; \ + \ +class PTABLE(T) { \ + PASSOC(T) *v; \ + unsigned size; \ + unsigned used; \ + enum { \ + FULL_NUM = 1, \ + FULL_DEN = 4, \ + INITIAL_SIZE = 17 \ + }; \ +public: \ + PTABLE(T)(); /* Create an empty table. */ \ + ~PTABLE(T)(); /* Delete a table, including its \ + values. */ \ + const char *define(const char *, T *);/* Define the value (arg2) for a key \ + (arg1). Return the copy in the \ + table of the key (arg1), or \ + possibly NULL if the value (arg2) \ + is NULL. */ \ + T *lookup(const char *); /* Return a pointer to the value of \ + the given key, if found in the \ + table, or NULL otherwise. */ \ + T *lookupassoc(const char **); /* Return a pointer to the value of \ + the given key, passed by reference,\ + and replace the key argument with \ + the copy found in the table, if \ + the key is found in the table. \ + Return NULL otherwise. */ \ + friend class PTABLE_ITERATOR(T); \ +}; + + +// Keys (which are strings) are allocated and freed by PTABLE. +// Values must be allocated by the caller (always using new[], not new) +// and are freed by PTABLE. + +// Define the implementations of the members of the types 'class PTABLE(T)', +// 'struct PASSOC(T)', 'class PTABLE_ITERATOR(T)' for the type 'T'. +#define implement_ptable(T) \ + \ +PASSOC(T)::PASSOC(T)() \ +: key(0), val(0) \ +{ \ +} \ + \ +PTABLE(T)::PTABLE(T)() \ +{ \ + v = new PASSOC(T)[size = INITIAL_SIZE]; \ + used = 0; \ +} \ + \ +PTABLE(T)::~PTABLE(T)() \ +{ \ + for (unsigned i = 0; i < size; i++) { \ + free(v[i].key); \ + /* XXX leak, because we don't know whether */ \ + /* 'free', 'delete', or 'delete[]' should be used */ \ + /* delete[] v[i].val; */ \ + } \ + delete[] v; \ +} \ + \ +const char *PTABLE(T)::define(const char *key, T *val) \ +{ \ + assert(key != 0); \ + unsigned long h = hash_string(key); \ + unsigned n; \ + for (n = unsigned(h % size); \ + v[n].key != 0; \ + n = (n == 0 ? size - 1 : n - 1)) \ + if (strcmp(v[n].key, key) == 0) { \ + /* XXX leak, because we don't know whether */ \ + /* 'free', 'delete', or 'delete[]' should be used */ \ + /* delete[] v[n].val; */ \ + v[n].val = val; \ + return v[n].key; \ + } \ + if (val == 0) \ + return 0; \ + if (used*FULL_DEN >= size*FULL_NUM) { \ + PASSOC(T) *oldv = v; \ + unsigned old_size = size; \ + size = next_ptable_size(size); \ + v = new PASSOC(T)[size]; \ + for (unsigned i = 0; i < old_size; i++) \ + if (oldv[i].key != 0) { \ + if (oldv[i].val == 0) \ + free(oldv[i].key); \ + else { \ + unsigned j; \ + for (j = unsigned(hash_string(oldv[i].key) % size); \ + v[j].key != 0; \ + j = (j == 0 ? size - 1 : j - 1)) \ + ; \ + v[j].key = oldv[i].key; \ + v[j].val = oldv[i].val; \ + } \ + } \ + for (n = unsigned(h % size); \ + v[n].key != 0; \ + n = (n == 0 ? size - 1 : n - 1)) \ + ; \ + delete[] oldv; \ + } \ + char *temp = (char*)malloc(strlen(key)+1); \ + strcpy(temp, key); \ + v[n].key = temp; \ + v[n].val = val; \ + used++; \ + return temp; \ +} \ + \ +T *PTABLE(T)::lookup(const char *key) \ +{ \ + assert(key != 0); \ + for (unsigned n = unsigned(hash_string(key) % size); \ + v[n].key != 0; \ + n = (n == 0 ? size - 1 : n - 1)) \ + if (strcmp(v[n].key, key) == 0) \ + return v[n].val; \ + return 0; \ +} \ + \ +T *PTABLE(T)::lookupassoc(const char **keyptr) \ +{ \ + const char *key = *keyptr; \ + assert(key != 0); \ + for (unsigned n = unsigned(hash_string(key) % size); \ + v[n].key != 0; \ + n = (n == 0 ? size - 1 : n - 1)) \ + if (strcmp(v[n].key, key) == 0) { \ + *keyptr = v[n].key; \ + return v[n].val; \ + } \ + return 0; \ +} \ + \ +PTABLE_ITERATOR(T)::PTABLE_ITERATOR(T)(PTABLE(T) *t) \ +: p(t), i(0) \ +{ \ +} \ + \ +int PTABLE_ITERATOR(T)::next(const char **keyp, T **valp) \ +{ \ + unsigned size = p->size; \ + PASSOC(T) *v = p->v; \ + for (; i < size; i++) \ + if (v[i].key != 0) { \ + *keyp = v[i].key; \ + *valp = v[i].val; \ + i++; \ + return 1; \ + } \ + return 0; \ +} + +// Local Variables: +// fill-column: 72 +// mode: C++ +// End: +// vim: set cindent noexpandtab shiftwidth=2 textwidth=72: diff --git a/src/include/refid.h b/src/include/refid.h new file mode 100644 index 0000000..9bf3a40 --- /dev/null +++ b/src/include/refid.h @@ -0,0 +1,34 @@ +// -*- C++ -*- +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +class reference_id { + int filename_id; + int pos; +public: + reference_id() : filename_id(-1) { } + reference_id(int fid, int off) : filename_id(fid), pos(off) { } + unsigned hash() const { return (filename_id << 4) + pos; } + int is_null() const { return filename_id < 0; } + friend inline int operator==(const reference_id &, const reference_id &); +}; + +inline int operator==(const reference_id &r1, const reference_id &r2) +{ + return r1.filename_id == r2.filename_id && r1.pos == r2.pos; +} diff --git a/src/include/relocate.h b/src/include/relocate.h new file mode 100644 index 0000000..851e2cc --- /dev/null +++ b/src/include/relocate.h @@ -0,0 +1,37 @@ +/* -*- C -*- */ +/* Provide relocation for macro and font files. + + Copyright (C) 2005-2020 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this program. If not, see . */ + +#ifdef __cplusplus +extern char *curr_prefix; +extern size_t curr_prefix_len; + +void set_current_prefix (); +char *xdirname (char *s); +char *searchpath (const char *name, const char *pathp); +#endif + +/* This function has C linkage. */ +extern +#ifdef __cplusplus +"C" +#endif +char *relocatep (const char *path); + +#ifdef __cplusplus +char *relocate (const char *path); +#endif diff --git a/src/include/search.h b/src/include/search.h new file mode 100644 index 0000000..eb9a039 --- /dev/null +++ b/src/include/search.h @@ -0,0 +1,100 @@ +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +class search_item; +class search_item_iterator; + +class search_list { +public: + search_list(); + ~search_list(); + void add_file(const char *fn, int silent = 0); + int nfiles() const; +private: + search_item *list; + int niterators; + int next_fid; + friend class search_list_iterator; +}; + +class bmpattern; + +class linear_searcher { + const char *ignore_fields; + int truncate_len; + bmpattern **keys; + int nkeys; + const char *search_and_check(const bmpattern *key, const char *buf, + const char *bufend, const char **start = 0) + const; + int check_match(const char *buf, const char *bufend, const char *match, + int matchlen, const char **cont, const char **start) + const; +public: + linear_searcher(const char *query, int query_len, + const char *ign, int trunc); + ~linear_searcher(); + int search(const char *buf, const char *bufend, + const char **startp, int *lengthp) const; +}; + +class search_list_iterator { + search_list *list; + search_item *ptr; + search_item_iterator *iter; + char *query; + linear_searcher searcher; +public: + search_list_iterator(search_list *, const char *query); + ~search_list_iterator(); + int next(const char **, int *, reference_id * = 0); +}; + +class search_item { +protected: + char *name; + int filename_id; +public: + search_item *next; + search_item(const char *nm, int fid); + virtual search_item_iterator *make_search_item_iterator(const char *) = 0; + virtual ~search_item(); + int is_named(const char *) const; + virtual int next_filename_id() const; +}; + +class search_item_iterator { + char shut_g_plus_plus_up; +public: + virtual ~search_item_iterator(); + virtual int next(const linear_searcher &, const char **ptr, int *lenp, + reference_id *) = 0; +}; + +search_item *make_index_search_item(const char *filename, int fid); +search_item *make_linear_search_item(int fd, const char *filename, int fid); + +extern int linear_truncate_len; +extern const char *linear_ignore_fields; +extern bool do_verify; + +// Local Variables: +// fill-column: 72 +// mode: C++ +// End: +// vim: set cindent noexpandtab shiftwidth=2 textwidth=72: diff --git a/src/include/searchpath.h b/src/include/searchpath.h new file mode 100644 index 0000000..2dda4e8 --- /dev/null +++ b/src/include/searchpath.h @@ -0,0 +1,30 @@ +// -*- C++ -*- +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +class search_path { + char *dirs; + unsigned init_len; +public: + search_path(const char *envvar, const char *standard, + int add_home, int add_current); + ~search_path(); + void command_line_dir(const char *); + FILE *open_file(const char *, char **); + FILE *open_file_cautious(const char *, char ** = 0, const char * = 0); +}; diff --git a/src/include/stringclass.h b/src/include/stringclass.h new file mode 100644 index 0000000..ca0bf85 --- /dev/null +++ b/src/include/stringclass.h @@ -0,0 +1,194 @@ +/* Copyright (C) 1989-2020 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 3 of the License, 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 this program. If not, see . */ + +#include +#include +#include + +// Ensure that the first declaration of functions that are later +// declared as inline declares them as inline. + +class string; + +inline string operator+(const string &, const string &); +inline string operator+(const string &, const char *); +inline string operator+(const char *, const string &); +inline string operator+(const string &, char); +inline string operator+(char, const string &); +inline int operator==(const string &, const string &); +inline int operator!=(const string &, const string &); + +class string { +public: + string(); + string(const string &); + string(const char *); + string(const char *, int); + string(char); + + ~string(); + + string &operator=(const string &); + string &operator=(const char *); + string &operator=(char); + + string &operator+=(const string &); + string &operator+=(const char *); + string &operator+=(char); + void append(const char *, int); + + int length() const; + int empty() const; + int operator*() const; + + string substring(int i, int n) const; + + char &operator[](int); + char operator[](int) const; + + void set_length(int i); + const char *contents() const; + int search(char) const; + char *extract() const; + void remove_spaces(); + void clear(); + void move(string &); + + friend string operator+(const string &, const string &); + friend string operator+(const string &, const char *); + friend string operator+(const char *, const string &); + friend string operator+(const string &, char); + friend string operator+(char, const string &); + + friend int operator==(const string &, const string &); + friend int operator!=(const string &, const string &); + friend int operator<=(const string &, const string &); + friend int operator<(const string &, const string &); + friend int operator>=(const string &, const string &); + friend int operator>(const string &, const string &); + +private: + char *ptr; + int len; + int sz; + + string(const char *, int, const char *, int); // for use by operator+ + void grow1(); +}; + + +inline char &string::operator[](int i) +{ + assert(i >= 0 && i < len); + return ptr[i]; +} + +inline char string::operator[](int i) const +{ + assert(i >= 0 && i < len); + return ptr[i]; +} + +inline int string::length() const +{ + return len; +} + +inline int string::empty() const +{ + return len == 0; +} + +inline int string::operator*() const +{ + return len; +} + +inline const char *string::contents() const +{ + return ptr; +} + +inline string operator+(const string &s1, const string &s2) +{ + return string(s1.ptr, s1.len, s2.ptr, s2.len); +} + +inline string operator+(const string &s1, const char *s2) +{ +#ifdef __GNUG__ + if (s2 == 0) + return s1; + else + return string(s1.ptr, s1.len, s2, strlen(s2)); +#else + return s2 == 0 ? s1 : string(s1.ptr, s1.len, s2, strlen(s2)); +#endif +} + +inline string operator+(const char *s1, const string &s2) +{ +#ifdef __GNUG__ + if (s1 == 0) + return s2; + else + return string(s1, strlen(s1), s2.ptr, s2.len); +#else + return s1 == 0 ? s2 : string(s1, strlen(s1), s2.ptr, s2.len); +#endif +} + +inline string operator+(const string &s, char c) +{ + return string(s.ptr, s.len, &c, 1); +} + +inline string operator+(char c, const string &s) +{ + return string(&c, 1, s.ptr, s.len); +} + +inline int operator==(const string &s1, const string &s2) +{ + return (s1.len == s2.len + && (s1.len == 0 || memcmp(s1.ptr, s2.ptr, s1.len) == 0)); +} + +inline int operator!=(const string &s1, const string &s2) +{ + return (s1.len != s2.len + || (s1.len != 0 && memcmp(s1.ptr, s2.ptr, s1.len) != 0)); +} + +inline string string::substring(int i, int n) const +{ + assert(i >= 0 && i + n <= len); + return string(ptr + i, n); +} + +inline string &string::operator+=(char c) +{ + if (len >= sz) + grow1(); + ptr[len++] = c; + return *this; +} + +void put_string(const string &, FILE *); + +string as_string(int); diff --git a/src/include/symbol.h b/src/include/symbol.h new file mode 100644 index 0000000..047255d --- /dev/null +++ b/src/include/symbol.h @@ -0,0 +1,88 @@ +/* Copyright (C) 1989-2023 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 3 of the License, 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 this program. If not, see . */ + +#include // uintptr_t + +#define DONT_STORE 1 +#define MUST_ALREADY_EXIST 2 + +class symbol { + static const char **table; + static int table_used; + static int table_size; + static char *block; + static int block_size; + const char *s; +public: + symbol(const char *p, int how = 0); + symbol(); + uintptr_t hash() const; + int operator ==(symbol) const; + int operator !=(symbol) const; + const char *contents() const; + int is_null() const; + int is_empty() const; +}; + + +extern const symbol NULL_SYMBOL; +extern const symbol EMPTY_SYMBOL; + +inline symbol::symbol() : s(0) +{ +} + +inline int symbol::operator==(symbol p) const +{ + return s == p.s; +} + +inline int symbol::operator!=(symbol p) const +{ + return s != p.s; +} + +inline uintptr_t symbol::hash() const +{ + return reinterpret_cast(s); +} + +inline const char *symbol::contents() const +{ + return s; +} + +inline int symbol::is_null() const +{ + return s == 0; +} + +inline int symbol::is_empty() const +{ + return s != 0 && *s == 0; +} + +symbol concat(symbol, symbol); + +extern symbol default_symbol; + +// Local Variables: +// fill-column: 72 +// mode: C++ +// End: +// vim: set cindent noexpandtab shiftwidth=2 textwidth=72: diff --git a/src/include/unicode.h b/src/include/unicode.h new file mode 100644 index 0000000..670864b --- /dev/null +++ b/src/include/unicode.h @@ -0,0 +1,63 @@ +// -*- C++ -*- +/* Copyright (C) 2002-2020 Free Software Foundation, Inc. + Written by Werner Lemberg + +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 3 of the License, 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 this program. If not, see . */ + +// Convert a groff glyph name to a string containing an underscore-separated +// list of Unicode code points. For example, +// +// '-' -> '2010' +// ',c' -> '00E7' +// 'fl' -> '0066_006C' +// +// Return NULL if there is no equivalent. +const char *glyph_name_to_unicode(const char *); + +// Convert a string containing an underscore-separated list of Unicode code +// points to a groff glyph name. For example, +// +// '2010' -> 'hy' +// '0066_006C' -> 'fl' +// +// Return NULL if there is no equivalent. +const char *unicode_to_glyph_name(const char *); + +// Convert a string containing a precomposed Unicode character to a string +// containing an underscore-separated list of Unicode code points, +// representing its canonical decomposition. Also perform compatibility +// equivalent replacement. For example, +// +// '1F3A' -> '0399_0313_0300' +// 'FA6A' -> '983B' +// +// Return NULL if there is no equivalent. +const char *decompose_unicode(const char *); + +// Test whether the given string denotes a Unicode character. It must +// be of the form 'uNNNN', obeying the following rules. +// +// - 'NNNN' must consist of at least 4 hexadecimal digits in upper case. +// - If there are more than 4 hexadecimal digits, the leading one must not +// be zero, +// - 'NNNN' must denote a valid Unicode code point (U+0000..U+10FFFF, +// excluding surrogate code points. +// +// Return a pointer to 'NNNN' (skipping the leading 'u' character) in case +// of success, NULL otherwise. +const char *check_unicode_name(const char *); + +// end of unicode.h -- cgit v1.2.3