stringsi.inc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by the Free Pascal development team
  4. Processor independent part for strings and sysutils units
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. function strcat(dest,source : pchar) : pchar;
  12. begin
  13. strcopy(strend(dest),source);
  14. strcat:=dest;
  15. end;
  16. function strlcat(dest,source : pchar;l : SizeInt) : pchar;
  17. var
  18. destend : pchar;
  19. begin
  20. destend:=strend(dest);
  21. dec(l,destend-dest);
  22. if l>0 then
  23. strlcopy(destend,source,l);
  24. strlcat:=dest;
  25. end;
  26. function strmove(dest,source : pchar;l : SizeInt) : pchar;
  27. begin
  28. move(source^,dest^,l);
  29. strmove:=dest;
  30. end;
  31. function strpos(str1,str2 : pchar) : pchar;
  32. var
  33. p : pchar;
  34. lstr2 : SizeInt;
  35. begin
  36. strpos:=nil;
  37. if (str1 = nil) or (str2 = nil) then
  38. exit;
  39. p:=strscan(str1,str2^);
  40. if p=nil then
  41. exit;
  42. lstr2:=strlen(str2);
  43. while p<>nil do
  44. begin
  45. if strlcomp(p,str2,lstr2)=0 then
  46. begin
  47. strpos:=p;
  48. exit;
  49. end;
  50. inc(p);
  51. p:=strscan(p,str2^);
  52. end;
  53. end;