stringsi.inc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. strcopy(strend(dest),source);
  15. strcat:=dest;
  16. end;
  17. function strlcat(dest,source : pchar;l : longint) : pchar;
  18. var
  19. destend : pchar;
  20. begin
  21. destend:=strend(dest);
  22. dec(l,destend-dest);
  23. strlcopy(destend,source,l);
  24. strlcat:=dest;
  25. end;
  26. function strmove(dest,source : pchar;l : longint) : 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 : longint;
  35. begin
  36. strpos:=nil;
  37. p:=strscan(str1,str2^);
  38. if p=nil then
  39. exit;
  40. lstr2:=strlen(str2);
  41. while p<>nil do
  42. begin
  43. if strlcomp(p,str2,lstr2)=0 then
  44. begin
  45. strpos:=p;
  46. exit;
  47. end;
  48. inc(longint(p));
  49. p:=strscan(p,str2^);
  50. end;
  51. end;
  52. function strnew(p : pchar) : pchar;
  53. var
  54. len : longint;
  55. begin
  56. strnew:=nil;
  57. if (p=nil) or (p^=#0) then
  58. exit;
  59. len:=strlen(p)+1;
  60. getmem(strnew,len);
  61. if strnew<>nil then
  62. strmove(strnew,p,len);
  63. end;
  64. {
  65. $Log$
  66. Revision 1.3 1999-09-01 09:25:10 peter
  67. * fixed return of strcat,strlcat
  68. Revision 1.2 1999/02/25 10:05:07 michael
  69. + Added header and log
  70. }