static char phone2[LEN_PHONE2 + 1], dept[LEN_DEPT + 1], title[LEN_TITLE + 1];
static char username[LEN_USERNAME + 1], host[LEN_HOST + 1];
int ends_sr, ends_jr, ends_iii, ends_iv, ends_ii, ends_v;
- char *p;
+ char *p, *q;
if (!fgets(buf, sizeof(buf), in))
return NULL;
e.id = id;
- e.address = strtrim(office);
+ /* The following is really gross, but it happens to successfully convert
+ * new-style Warehouse office descriptions into (more-readable) old-style
+ * Personnel Office office descriptions.
+ */
+ e.address = p = strtrim(office);
+ while (*p && !isspace(*p))
+ p++;
+ q = p;
+ while (isspace(*q))
+ q++;
+ if (*q && q < e.address + LEN_OFFICE / 2)
+ {
+ *p++ = '-';
+ while (*q && q < e.address + LEN_OFFICE / 2)
+ {
+ if (*q != ' ' && *q != '-')
+ *p++ = *q;
+ if (q > p)
+ *q = ' ';
+ q++;
+ }
+ memset(p, ' ', q - p);
+ }
+
+ p = e.address + LEN_OFFICE / 2;
+ while (*p && !isspace(*p))
+ p++;
+ q = p;
+ while (isspace(*q))
+ q++;
+ if (*q)
+ {
+ *p++ = '-';
+ while (*q)
+ {
+ if (*q != ' ' && *q != '-')
+ *p++ = *q;
+ if (q > p)
+ *q = ' ';
+ q++;
+ }
+ memset(p, ' ', q - p);
+ }
+ strtrim(e.address);
+
e.phone = strtrim(phone);
e.phone2 = strtrim(phone2);
e.dept = strtrim(dept);