Allow non-US-ASCII characters in the GECOS fields ("name", "room number",

and "other info" fields).
This commit is contained in:
nekral-guest
2008-04-27 00:24:49 +00:00
parent 4d7d6a1a9f
commit 4196525702
5 changed files with 50 additions and 18 deletions

View File

@@ -38,21 +38,31 @@
/*
* valid_field - insure that a field contains all legal characters
*
* The supplied field is scanned for non-printing and other illegal
* characters. If any illegal characters are found, valid_field
* returns -1. Zero is returned for success.
* The supplied field is scanned for non-printable and other illegal
* characters.
* + -1 is returned if an illegal character is present.
* + 1 is returned if no illegal characters are present, but the field
* contains a non-printable character.
* + 0 is returned otherwise.
*/
int valid_field (const char *field, const char *illegal)
{
const char *cp;
int err = 0;
for (cp = field;
*cp && isprint (*cp & 0x7F) && !strchr (illegal, *cp); cp++);
for (cp = field; *cp && !strchr (illegal, *cp); cp++);
if (*cp)
return -1;
else
return 0;
if (*cp) {
err = -1;
} else {
for (cp = field; *cp && isprint (*cp); cp++);
if (*cp) {
err = 1;
}
}
return err;
}
/*