Skip to content

Commit

Permalink
lib/chkname.c: is_valid_name(): Use ispfchar() to simplify
Browse files Browse the repository at this point in the history
In the first case, we can do the transformation because a few lines
above, we explicitly reject a name starting with a '-'.

In the second case, we're obviously using ispfchar() instead of its
pattern.

Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar committed Dec 24, 2024
1 parent cddc517 commit 1547832
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions lib/chkname.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#include "defines.h"
#include "chkname.h"
#include "ctype/ispfchar.h"
#include "string/ctype/strchrisascii/strchriscntrl.h"
#include "string/ctype/strisascii/strisdigit.h"
#include "string/strcmp/streq.h"
Expand Down Expand Up @@ -84,10 +85,7 @@ is_valid_name(const char *name)
* sake of Samba 3.x "add machine script"
*/

if (!(isalnum(*name) ||
*name == '_' ||
*name == '.'))
{
if (!ispfchar(*name)) {
errno = EILSEQ;
return false;
}
Expand All @@ -96,12 +94,7 @@ is_valid_name(const char *name)
if (streq(name, "$")) // Samba
return true;

if (!(isalnum(*name) ||
*name == '_' ||
*name == '.' ||
*name == '-'
))
{
if (!ispfchar(*name)) {
errno = EILSEQ;
return false;
}
Expand Down

0 comments on commit 1547832

Please sign in to comment.