Recent

Author Topic: PCRE  (Read 2732 times)

BubikolRamios

  • Full Member
  • ***
  • Posts: 188
PCRE
« on: February 10, 2015, 03:25:36 am »
In hope this will support negative look behind ...
source: http://www.bit2bitsoft.ro/wp-content/uploads/2013/04/PCRELibrary.zip

Code: [Select]

unit pcre;
{
 PCREWrapper library
 Delphi Regular Expressions  Wrapper for PCRE library

 Copyright (c) 2013 Mihai Sinescu, Bucharest, Romania 

..... 

function  _pcre_config; external;   



Quote
pcre.pas(445,23) Fatal: Syntax error, ":" expected but ";" found

What can I do here ?
« Last Edit: February 10, 2015, 03:28:15 am by BubikolRamios »
lazarus-2.0.2-fpc-3.0.4-win32

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: PCRE
« Reply #1 on: February 10, 2015, 03:42:43 am »
Code: [Select]

function  _pcre_config; external;   



Functions must have a result if it does not have one then use procedure instead eg

Code: [Select]

function  _pcre_config:integer; external;   

or
Code: [Select]

procedure _pcre_config; external;   

Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

BubikolRamios

  • Full Member
  • ***
  • Posts: 188
Re: PCRE
« Reply #2 on: February 10, 2015, 03:53:15 am »
Not my source, should kind of work out of box.

looked again

Code: [Select]
{$LINK pcre\pcre_config.obj} // if that makes it work (no complaints) in delphi 7
function  _pcre_config; external;   


This makes no compalints in delphi 7. Does other complaints.
« Last Edit: February 10, 2015, 03:55:54 am by BubikolRamios »
lazarus-2.0.2-fpc-3.0.4-win32

engkin

  • Hero Member
  • *****
  • Posts: 2513
Re: PCRE
« Reply #3 on: February 10, 2015, 04:07:27 am »
Then use Delphi mode: add -Sd to Others

Edit:
The PCRELibrary comes with OMF32 object files. I suppose you have to convert them to COFF format. Use ObjConv.
« Last Edit: February 10, 2015, 04:22:40 am by engkin »

totya

  • Hero Member
  • *****
  • Posts: 577
Re: PCRE
« Reply #4 on: July 31, 2019, 01:46:12 pm »
Hi, thanks, but it doesn't help to much. I try to convert a similar package.
I inserted {$MODE Delphi} to the pcre.pas.

with old obj files, I got warning:
Quote
illegal COFF magix changed to

So, convert:
Quote
for %%f in (files_in\*.obj) do objconv.exe -fcoff files_in\%%~nxf files_out\%%~nxf

Convert messages are similar:
Quote
Input file: files_in\pcre_compile.obj, output file: files_out\pcre_compile.obj
Converting from OMF32 to COFF32
Checksums are zero
Warning 1211: 29 comment records ignored

  0 Debug sections removed
  0 Exception sections removed

With new converted COFF obj files I got message when a compile a project (only PerlRegEx; in the uses line, without any code):
 
Quote
project1.lpr(21,1) Error: Internal error 200205172

The other way (and best, if I want x64 code), if I can compile directly from the  c source, borland makefile is present in the package:

Code: Pascal  [Select]
  1. #
  2. # makefile to make pcre .obj files using Borland's C++ compiler bcc32
  3. # derived from a makefile generated by BCB6' bpr2mak
  4. #
  5. # if pcre source directory is different from $(JCL)\source\pcre-7.7, use
  6. # "make -Dpcresrc=<path to pcre sources>" to tell make where to find the
  7. # source files
  8. #
  9. # Make.exe needs to reside in the same directory as bcc32.exe.
  10. # For example, if you have Borlands free C++ v. 5.5 compiler (available from
  11. # http://www.borland.com/products/downloads/download_cbuilder.html#) installed:
  12. #
  13. # >C:\Program Files\Borland\BCC55\Bin\make
  14. #
  15. # or, if you want to use C++ Builder 6:
  16. #
  17. # >C:\Program Files\Borland\CBuilder6\Bin\make
  18. #
  19. # or, if you want to use Borland Developer Studio 2006:
  20. #
  21. # >C:\Program files\Borland\BDS\4.0\bin\make
  22. #
  23. # To choose the target CPU, pass "-DCPU=n" as option to make, with n being a
  24. # number between 3 and 6, with the following meanings:
  25. #
  26. #   n   Target CPU (or compatible)
  27. # --------------------------------
  28. #   3   80386
  29. #   4   80486
  30. #   5   Pentium (default)
  31. #   6   Pentium Pro
  32. #
  33. # Robert Rossmair, 2004-10-16
  34. #
  35.  
  36. CallingConvention = -pr
  37.  
  38. !if !$d(BCB)
  39. BCB = $(MAKEDIR)\..
  40. !endif
  41.  
  42. BCC = $(BCB)
  43.  
  44. !if !$d(pcresrc)
  45. pcresrc = ..\..\..\pcre-7.7
  46. !endif
  47.  
  48. !if !$d(CPU)
  49. CPU = 5         # Pentium
  50. !endif
  51.  
  52. # ---------------------------------------------------------------------------
  53. # IDE SECTION
  54. # ---------------------------------------------------------------------------
  55. # The following section of the project makefile is managed by the BCB IDE.
  56. # It is recommended to use the IDE to change any of the values in this
  57. # section.
  58. # ---------------------------------------------------------------------------
  59.  
  60. VERSION = BCB.06.00
  61. # ---------------------------------------------------------------------------
  62. OBJFILES = .\pcre_compile.obj .\pcre_config.obj .\pcre_dfa_exec.obj \
  63.   .\pcre_exec.obj .\pcre_fullinfo.obj .\pcre_get.obj .\pcre_globals.obj \
  64.   .\pcre_info.obj .\pcre_maketables.obj .\pcre_newline.obj \
  65.   .\pcre_ord2utf8.obj .\pcre_refcount.obj .\pcre_study.obj .\pcre_tables.obj \
  66.   .\pcre_try_flipped.obj .\pcre_ucd.obj .\pcre_valid_utf8.obj \
  67.   .\pcre_version.obj .\pcre_xclass.obj .\pcre_default_tables.obj
  68.  
  69. # ---------------------------------------------------------------------------
  70. DEBUGLIBPATH = $(BCB)\lib\debug
  71. RELEASELIBPATH = $(BCB)\lib\release
  72. USERDEFINES = SUPPORT_UTF8;SUPPORT_UCP
  73. SYSDEFINES = NO_STRICT;_NO_VCL;_RTLDLL
  74. INCLUDEPATH = $(pcresrc);$(BCC)\include;$(BCB)\include\vcl
  75. LIBPATH = $(BCB)\lib\obj;$(BCB)\lib
  76. # LIBPATH = $(pcresrc)
  77. WARNINGS= -wpar -w-aus
  78. PATHC = .;$(pcresrc)
  79. # PATHOBJ = .;$(LIBPATH)
  80. ALLLIB = import32.lib cw32i.lib
  81. # ---------------------------------------------------------------------------
  82. CFLAG1 = -O2 -Ve -X- -a8 -$(CPU) -b -d -k- -vi -tWM- -DHAVE_CONFIG_H
  83.  
  84. LFLAGS = -D"" -ap -Tpe -x -Gn
  85. # ---------------------------------------------------------------------------
  86. # MAKE SECTION
  87. # ---------------------------------------------------------------------------
  88. # This section of the project file is not used by the BCB IDE.  It is for
  89. # the benefit of building from the command-line using the MAKE utility.
  90. # ---------------------------------------------------------------------------
  91.  
  92. .autodepend
  93. # ---------------------------------------------------------------------------
  94.  
  95. !if !$d(BCC32)
  96. BCC32 = bcc32
  97. !endif
  98.  
  99. !if !$d(LINKER)
  100. LINKER = ilink32
  101. !endif
  102.  
  103. # ---------------------------------------------------------------------------
  104. !if $d(PATHC)
  105. .PATH.C   = $(PATHC)
  106. !endif
  107.  
  108. # ---------------------------------------------------------------------------
  109. pcre: includes tables $(OBJFILES)
  110.  
  111. # ---------------------------------------------------------------------------
  112. .c.obj:
  113.     $(BCC)\BIN\$(BCC32) -c $(CFLAG1) $(CallingConvention) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n$(@D) {$< }
  114.  
  115. includes:
  116.     copy /Y $(pcresrc)\pcre.h.generic $(pcresrc)\pcre.h
  117.     copy /Y $(pcresrc)\config.h.generic $(pcresrc)\config.h
  118.  
  119. tables:
  120.     $(BCC)\BIN\$(BCC32) -c -tWC $(CFLAG1) $(WARNINGS) -I$(INCLUDEPATH) -D$(USERDEFINES);$(SYSDEFINES) -n.\ $(pcresrc)\dftables.c
  121.     $(BCC)\BIN\$(LINKER) $(LFLAGS) -L$(LIBPATH) c0x32.obj .\dftables.obj, .\dftables.exe,, $(ALLLIB),,
  122.     del dftables.tds
  123.     del dftables.obj
  124.     dftables.exe pcre_default_tables.c
  125.     del dftables.exe
  126. # ---------------------------------------------------------------------------
  127.  

Ok, can I compile it with fpc?
« Last Edit: July 31, 2019, 01:50:59 pm by totya »