Allow for PATH_MAX not being defined on some systems. Use reasonable default

This commit is contained in:
Jean-Francois Dockes 2018-12-13 15:28:58 +01:00
parent 0e0075b207
commit 51aa31ba4b

View File

@ -1697,7 +1697,15 @@ static const char blurb0[] =
"# Values set in this file will override the system-wide values for the file\n" "# Values set in this file will override the system-wide values for the file\n"
"# with the same name in the central directory. The syntax for setting\n" "# with the same name in the central directory. The syntax for setting\n"
"# values is identical.\n" "# values is identical.\n"
; ;
// We just use path_max to print the path to /usr/share/recoll/examples
// inside the config file. At worse, the text is truncated (using
// snprintf). But 4096 should be enough :)
#ifndef PATH_MAX
#define MYPATHALLOC 4096
#else
#define MYPATHALLOC PATH_MAX
#endif
// Use uni2ascii -a K to generate these from the utf-8 strings // Use uni2ascii -a K to generate these from the utf-8 strings
// Swedish and Danish. // Swedish and Danish.
@ -1712,7 +1720,7 @@ static int ncffiles = sizeof(configfiles) / sizeof(char *);
bool RclConfig::initUserConfig() bool RclConfig::initUserConfig()
{ {
// Explanatory text // Explanatory text
const int bs = sizeof(blurb0)+PATH_MAX+1; const int bs = sizeof(blurb0)+MYPATHALLOC+1;
char blurb[bs]; char blurb[bs];
string exdir = path_cat(m_datadir, "examples"); string exdir = path_cat(m_datadir, "examples");
snprintf(blurb, bs, blurb0, exdir.c_str()); snprintf(blurb, bs, blurb0, exdir.c_str());
@ -1855,12 +1863,12 @@ using namespace std;
static char *thisprog; static char *thisprog;
static char usage [] = "\n" static char usage [] = "\n"
"-c: check a few things in the configuration files\n" "-c: check a few things in the configuration files\n"
"[-s subkey] -q param : query parameter value\n" "[-s subkey] -q param : query parameter value\n"
"-f : print some field data\n" "-f : print some field data\n"
" : default: print parameters\n" " : default: print parameters\n"
; ;
static void static void
Usage(void) Usage(void)
{ {