+
+/* This should be in an lclUtils.c file... */
+# ifndef NOLCL
+char *specFullName (char *specfile, /*@out@*/ char **inpath)
+{
+ /* extract the path and the specname associated with the given file */
+ char *specname = (char *) dmalloc (sizeof (*specname)
+ * (strlen (specfile) + 9));
+ char *ospecname = specname;
+ char *path = (char *) dmalloc (sizeof (*path) * (strlen (specfile)));
+ size_t size;
+ long int i, j;
+
+ /* initialized path to empty string or may have accidental garbage */
+ *path = '\0';
+
+ /*@-mayaliasunique@*/
+ strcpy (specname, specfile);
+ /*@=mayaliasunique@*/
+
+ /* trim off pathnames in specfile */
+ size = strlen (specname);
+
+ for (i = size_toInt (size) - 1; i >= 0; i--)
+ {
+ if (specname[i] == CONNECTCHAR)
+ {
+ /* strcpy (specname, (char *)specname+i+1); */
+ for (j = 0; j <= i; j++) /* include '/' */
+ {
+ path[j] = specname[j];
+ }
+
+ path[i + 1] = '\0';
+ specname += i + 1;
+ break;
+ }
+ }
+
+ /*
+ ** also remove .lcl file extension, assume it's the last extension
+ ** of the file name
+ */
+
+ size = strlen (specname);
+
+ for (i = size_toInt (size) - 1; i >= 0; i--)
+ {
+ if (specname[i] == '.')
+ {
+ specname[i] = '\0';
+ break;
+ }
+ }
+
+ *inpath = path;
+
+ /*
+ ** If specname no longer points to the original char,
+ ** we need to allocate a new pointer and copy the string.
+ */
+
+ if (specname != ospecname) {
+ char *rspecname = (char *) dmalloc (sizeof (*rspecname) * (strlen (specname) + 1));
+ strcpy (rspecname, specname); /* evs 2000-05-16: Bug: was ospecname! */
+ sfree (ospecname);
+ return rspecname;
+ }
+
+ return specname;
+}
+# endif