- if (strcmp(filename, linkname) == 0) {
- _nc_warning("self-synonym ignored");
- }
- else if (stat(linkname, &statbuf) >= 0 &&
- statbuf.st_mtime < start_time)
- {
- _nc_warning("alias %s multiply defined.", ptr);
- }
- else if (_nc_access(linkname, W_OK) == 0)
+ if (strlen(first_name) >= sizeof(filename) - (2 + LEAF_LEN))
+ _nc_warning("terminal name too long.");
+
+ sprintf(filename, LEAF_FMT "/%s", first_name[0], first_name);
+
+ /*
+ * Has this primary name been written since the first call to
+ * write_entry()? If so, the newer write will step on the older,
+ * so warn the user.
+ */
+ if (start_time > 0 &&
+ stat(filename, &statbuf) >= 0
+ && statbuf.st_mtime >= start_time) {
+ _nc_warning("name multiply defined.");
+ }
+
+ check_writeable(first_name[0]);
+ write_file(filename, tp);
+
+ if (start_time == 0) {
+ if (stat(filename, &statbuf) < 0
+ || (start_time = statbuf.st_mtime) == 0) {
+ _nc_syserr_abort("error obtaining time from %s/%s",
+ _nc_tic_dir(0), filename);
+ }
+ }
+ while (*other_names != '\0') {
+ ptr = other_names++;
+ while (*other_names != '|' && *other_names != '\0')
+ other_names++;
+
+ if (*other_names != '\0')
+ *(other_names++) = '\0';
+
+ if (strlen(ptr) > sizeof(linkname) - (2 + LEAF_LEN)) {
+ _nc_warning("terminal alias %s too long.", ptr);
+ continue;
+ }
+ if (strchr(ptr, '/') != 0) {
+ _nc_warning("cannot link alias %s.", ptr);
+ continue;
+ }
+
+ check_writeable(ptr[0]);
+ sprintf(linkname, LEAF_FMT "/%s", ptr[0], ptr);
+
+ if (strcmp(filename, linkname) == 0) {
+ _nc_warning("self-synonym ignored");
+ } else if (stat(linkname, &statbuf) >= 0 &&
+ statbuf.st_mtime < start_time) {
+ _nc_warning("alias %s multiply defined.", ptr);
+ } else if (_nc_access(linkname, W_OK) == 0)