Oops...

2014-03-12 15:08 GMT-03:00 silvioprog <[email protected]>:
[...]

> // new
> function ValidPassword(const S: string): Boolean;
> var
>   P: PChar;
>   F: Boolean;
>   L: Boolean = False;
>   U: Boolean = False;
>   N: Boolean = False;
> begin
>   P := PChar(S);
>   while P^ <> #0 do
>   begin
>     case P^ of
>       #48..#57: N := True;
>       #65..#90: U := True;
>       #97..#122: L := True;
>     else
>       F := P^ = #195;
>       if F then
>         case P[1] of
>           #128..#159: U := True;
>           #160..#191: L := True;
>         end;
>     end;
>     Inc(P);
>   end;
>   Result := L and U and N;
> end;
>

Correct function is:

function ValidPassword(const S: string): Boolean;
var
  P: PChar;
  L: Boolean = False;
  U: Boolean = False;
  N: Boolean = False;
begin
  P := PChar(S);
  while P^ <> #0 do
  begin
    case P^ of
      #48..#57: N := True;
      #65..#90: U := True;
      #97..#122: L := True;
    else
      if P^ = #195 then
        case P[1] of
          #128..#159: U := True;
          #160..#191: L := True;
        end;
    end;
    Inc(P);
  end;
  Result := L and U and N;
end;

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to