-/* $Id $
+/* $Id$
*
* Put a name into Moira-canonical form
*
strncpy(first, ifnm, FIRST_LEN);
}
-void FixCase(char *p)
+void FixCase(unsigned char *p)
{
- int cflag; /* convert to lcase, unless at start or following */
- /* a space or punctuation mark (e.g., '-') */
+ int up; /* Should next letter be uppercase */
+ int pos; /* Position within word */
- for (cflag = 0; *p; p++)
+ for (up = 1, pos = 1; *p; p++, pos++)
{
- if (cflag && isupper(*p))
+ if (!up && isupper(*p))
*p = tolower(*p);
- else if (!cflag && islower(*p))
+ else if (up && islower(*p))
*p = toupper(*p);
- if (isalpha(*p))
- cflag = 1;
+
+ if (isalpha(*p)) /* If letter, next letter should be lower */
+ up = 0;
+ else if (isspace(*p)) /* If space, next letter should be upper */
+ {
+ pos = 0;
+ up = 1;
+ }
+ else if (*p == '\'') /* If ', next letter should be upper only */
+ up = (pos == 2); /* if the ' is the 2nd char in the name */
+ else if (*p >= 0x80) /* If the high bit is set, don't touch it. */
+ up = 0;
else
- cflag = 0;
+ up = 1; /* If other punctuation (eg, -), upper */
}
}
}
}
+/* XXX no way to avoid possible buffer overrun here since we don't know
+ how long nm is and we're trying to make it one longer */
void LookForSt(char *nm) /* ST PIERRE, etc. */
{
char temp[256];
*mi++ = *nm;
*mi = '\0';
}
+
+/* Function Name: RemoveHyphens
+ * Description: Removes all hyphens from the string passed to it.
+ * Arguments: str - the string to remove the hyphens from
+ * Returns: none
+ */
+
+void RemoveHyphens(char *str)
+{
+ char *hyphen;
+
+ while ((hyphen = strchr(str, '-')))
+ strcpy(hyphen, hyphen + 1);
+}