1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
/*
* showconfig.cc: Part of GNU CSSC.
*
*
* Copyright (C) 2001,2007 Free Software Foundation, Inc.
*
* 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 <http://www.gnu.org/licenses/>.
*
*
* Code for showing the configuration of CSSC.
*
* This is called from version() in version.h. See the README and
* INSTALL files for details of the specific configuration options
* which are possible.
*
* $Id: showconfig.cc,v 1.7 2008/01/18 10:00:58 jay Exp $
*/
#include "cssc.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
static const char * copyright_explanation =
"Copyright (C) 1997-2008 Free Software Foundation, Inc.\n"
"\n"
"This program is free software: you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation, either version 3 of the License, or\n"
"(at your option) any later version.\n"
"\n"
"This program is distributed in the hope that it will be useful,\n"
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
"GNU General Public License for more details.\n"
"\n"
"You should have received a copy of the GNU General Public License\n"
"along with this program. If not, see <http://www.gnu.org/licenses/>.\n";
void show_copyright(void)
{
fprintf(stderr, "%s\n\n", copyright_explanation);
}
static void show_system_line_max(void)
{
long m = 0L;
#ifdef HAVE_SYSCONF
#ifdef _SC_LINE_MAX
if (0L == m)
m = sysconf(_SC_LINE_MAX);
if (m < 0L)
m = 0L; // there was an error, use LINE_MAX instead
#endif
#endif
#ifdef LINE_MAX
/* LINE_MAX is a conservative value - _SC_LINE_MAX is likely
* to be larger.
*/
if (0L == m)
m = LINE_MAX;
#endif
if (m)
{
fprintf(stderr,
"\n"
"The system diff utility should be able to handle lines of up\n"
"to %ld characters, and perhaps more. You are using %s as your\n"
"diff utility, but this program is not clever enough to determine\n"
"if that is the system utility (to which the _SC_LINE_MAX limit\n"
"shown above applies) or not. If %s is GNU diff, then there\n"
"will be no upper limit.\n",
m,
(CONFIG_DIFF_COMMAND), (CONFIG_DIFF_COMMAND));
#ifdef HAVE_GNU_DIFF
fprintf(stderr,
"\nWhen this version of CSSC was compiled, %s was GNU diff, "
"which has no upper limit on line lengths.\n",
(CONFIG_DIFF_COMMAND));
#endif
}
}
void show_config_info(void)
{
static const char * const enabled = "enabled";
static const char * const disabled = "disabled";
bool binary_ok = binary_file_creation_allowed();
long int line_max = max_sfile_line_len();
fprintf(stderr,"CURRENT CONFIGURATION:\n");
fprintf(stderr,
"Binary file support (compiled-in default): %s\n",
#ifdef CONFIG_DISABLE_BINARY_SUPPORT
disabled
#else
enabled
#endif
);
fprintf(stderr,
"Binary file support (as overridden by $CSSC_BINARY_SUPPORT): %s\n",
binary_ok ? enabled : disabled );
fprintf(stderr,
"Maximum body line length (compiled-in default): %ld\n",
(long int) CONFIG_MAX_BODY_LINE_LENGTH);
fprintf(stderr,
"Maximum body line length (as overridden by "
"$CSSC_MAX_LINE_LENGTH): %ld\n",
line_max);
fprintf(stderr,"\n");
fprintf(stderr, "Commentary:\n");
if (binary_ok)
{
fprintf(stderr, "%s",
"Binary file support is enabled; this means that CSSC\n"
"will create an encoded SCCS file if you pass the \"-b\"\n"
"option to \"admin\", or if you create an SCCS file from\n"
"an input file which the SCCS file format cannot represent in\n"
"text format.\n"
);
}
else
{
fprintf(stderr, "%s",
"Binary file support is disabled; this means that CSSC\n"
"will not create encoded SCCS files, but will handle them\n"
"both for reading and writing, if it finds already encoded\n"
"files.\n"
);
}
fprintf(stderr,
"Set the environment variable CSSC_BINARY_SUPPORT "
"to change this.\n\n");
if (line_max)
{
fprintf(stderr,
"Lines in the main body of the SCCS files that CSSC produces\n"
"are limited to %ld characters; input lines longer than this\n"
"will cause a fatal error. This means that CSSC can fail to\n"
"interoperate with SCCS implementations which limit the length\n"
"of a body line to less than %ld characters, or fail to\n"
"correctly modify SCCS files produced by SCCS implementations\n"
"which has a limit which is greater than %ld characters.\n",
line_max,
line_max,
line_max
);
}
else
{
fprintf(stderr,
"Lines in the main body of the SCCS files that CSSC produces\n"
"are not limited in length. This means that CSSC can fail to\n"
"interoperate with SCCS implementations which limit the length\n"
"of a body line to some fixed number.\n");
}
fprintf(stderr,
"Set the environment variable CSSC_MAX_LINE_LENGTH "
"to change this.\n");
show_system_line_max();
}
|