From: danw Date: Sun, 20 Dec 1998 21:33:00 +0000 (+0000) Subject: convert Warehouse-style office numbers to the more-readable Personnel X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/b92021f77ee66fd9062716a313f449d48a602c9d convert Warehouse-style office numbers to the more-readable Personnel data feed style. (Gross, but it works.) --- diff --git a/regtape/employee.pc b/regtape/employee.pc index 48bb9e4a..6c419a52 100644 --- a/regtape/employee.pc +++ b/regtape/employee.pc @@ -172,7 +172,7 @@ struct entry *get_next_entry(FILE *in) 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; @@ -238,7 +238,51 @@ struct entry *get_next_entry(FILE *in) 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);