- char const m4sugar[] = "m4sugar/m4sugar.m4";
- char const m4bison[] = "bison.m4";
- char *full_m4sugar;
- char *full_m4bison;
- char *full_skeleton;
- char const *p;
- char const *m4 = (p = getenv ("M4")) ? p : M4;
- char const *pkgdatadir = compute_pkgdatadir ();
- size_t skeleton_size = strlen (skeleton) + 1;
- size_t pkgdatadirlen = strlen (pkgdatadir);
- while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
- pkgdatadirlen--;
- full_skeleton = xmalloc (pkgdatadirlen + 1
- + (skeleton_size < sizeof m4sugar
- ? sizeof m4sugar : skeleton_size));
- strncpy (full_skeleton, pkgdatadir, pkgdatadirlen);
- full_skeleton[pkgdatadirlen] = '/';
- strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
- full_m4sugar = xstrdup (full_skeleton);
- strcpy (full_skeleton + pkgdatadirlen + 1, m4bison);
- full_m4bison = xstrdup (full_skeleton);
- if (mbschr (skeleton, '/'))
- strcpy (full_skeleton, skeleton);
- else
- strcpy (full_skeleton + pkgdatadirlen + 1, skeleton);
+ char const *m4 = (m4 = getenv ("M4")) ? m4 : M4;
+ char const *datadir = pkgdatadir ();
+ char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL);
+ char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL);
+ char *skel = (IS_PATH_WITH_DIR (skeleton)
+ ? xstrdup (skeleton)
+ : xconcatenated_filename (datadir, skeleton, NULL));