3 * Put a name into Moira-canonical form
5 * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
6 * For copying and distribution information, please see the file
10 #include <mit-copyright.h>
21 void FixName(char *ilnm, char *ifnm, char *last, char *first, char *middle)
23 int ends_jr = 0, ends_sr = 0;
24 int ends_iii = 0, ends_iv = 0, ends_ii = 0, ends_v = 0;
31 TrimTrailingSpace(ilnm);
32 LookForJrAndIII(ilnm, &ends_jr, &ends_sr,
33 &ends_ii, &ends_iii, &ends_iv, &ends_v);
37 strncpy(last, ilnm, LAST_LEN);
39 /* First name & middle initial ... */
41 TrimTrailingSpace(ifnm);
42 LookForJrAndIII(ifnm, &ends_jr, &ends_sr,
43 &ends_ii, &ends_iii, &ends_iv, &ends_v);
45 GetMidInit(ifnm, middle);
48 strncpy(first, ifnm, FIRST_LEN);
53 int cflag; /* convert to lcase, unless at start or following */
54 /* a space or punctuation mark (e.g., '-') */
56 for (cflag = 0; *p; p++)
58 if (cflag && isupper(*p))
60 else if (!cflag && islower(*p))
69 void LookForJrAndIII(char *nm, int *pends_jr, int *pends_sr, int *pends_ii,
70 int *pends_iii, int *pends_iv, int *pends_v)
74 if (len >= 4 && !strcmp(nm + len - 3, " JR"))
79 else if (len >= 4 && !strcmp(nm + len - 3, " SR"))
84 else if (len >= 4 && !strcmp(nm + len - 3, " IV"))
89 else if (len >= 5 && !strcmp(nm + len - 4, " JR."))
94 else if (len >= 5 && !strcmp(nm + len - 4, " III"))
99 else if (len >= 4 && !strcmp(nm + len - 3, " II"))
104 else if (len >= 3 && !strcmp(nm + len - 2, " V"))
111 /* XXX no way to avoid possible buffer overrun here since we don't know
112 how long nm is and we're trying to make it one longer */
113 void LookForSt(char *nm) /* ST PIERRE, etc. */
117 if (!strcmp(nm, "ST "))
119 strcpy(temp, nm + 3);
125 void LookForO(char *nm) /* O BRIEN, etc. */
127 if (!strcmp(nm, "O ") && isalpha(nm[2]))
131 void TrimTrailingSpace(char *ip)
134 for (p = ip + strlen(ip) - 1; p >= ip && isspace(*p); p--)
138 void GetMidInit(char *nm, char *mi)
140 while (*nm && !isspace(*nm))
144 while (*nm && isspace(*nm))