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

@ -1698,6 +1698,14 @@ static const char blurb0[] =
"# 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());