]> andersk Git - moira.git/commitdiff
convert Warehouse-style office numbers to the more-readable Personnel
authordanw <danw>
Sun, 20 Dec 1998 21:33:00 +0000 (21:33 +0000)
committerdanw <danw>
Sun, 20 Dec 1998 21:33:00 +0000 (21:33 +0000)
data feed style. (Gross, but it works.)

regtape/employee.pc

index 48bb9e4a0a86c7bf9490f6ae797738e4a02b3057..6c419a52e379d29f46b38b17b06441217360a1f5 100644 (file)
@@ -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);
This page took 0.225285 seconds and 5 git commands to generate.