stringsi.inc 1.9 KB

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