Hello Matthew, On Fri, Jun 19, 2020 at 05:08:56PM +0100, Matthew Vernon wrote: > [can you reproduce with a little test program? but I think this is a build > issue not a pcre2 one at the moment]
The minimal program attached exhibits this behaviour as well. In stable: helge@samd:/tmp$ gcc -Duse_regexp=1 -g -O2 -c -o minimal.o minimal.c helge@samd:/tmp$ gcc -g -O2 -lpcre2-8 -Wl,-z,relro -o minimal minimal.o helge@samd:/tmp$ echo $? 0 In Sid chroot: root@samd:/tmp/linuxinfo-3.2.0# gcc -Duse_regexp=1 -g -O2 -c -o minimal.o minimal.c root@samd:/tmp/linuxinfo-3.2.0# gcc -g -O2 -lpcre2-8 -Wl,-z,relro -o minimal minimal.o /usr/bin/ld: minimal.o: in function `regstrcmp': /tmp/linuxinfo-3.2.0/minimal.c:50: undefined reference to `pcre2_compile_8' /usr/bin/ld: /tmp/linuxinfo-3.2.0/minimal.c:78: undefined reference to `pcre2_match_data_create_from_pattern_8' /usr/bin/ld: /tmp/linuxinfo-3.2.0/minimal.c:80: undefined reference to `pcre2_match_8' /usr/bin/ld: /tmp/linuxinfo-3.2.0/minimal.c:107: undefined reference to `pcre2_match_data_free_8' /usr/bin/ld: /tmp/linuxinfo-3.2.0/minimal.c:108: undefined reference to `pcre2_code_free_8' /usr/bin/ld: /tmp/linuxinfo-3.2.0/minimal.c:102: undefined reference to `pcre2_match_data_free_8' /usr/bin/ld: /tmp/linuxinfo-3.2.0/minimal.c:103: undefined reference to `pcre2_code_free_8' /usr/bin/ld: /tmp/linuxinfo-3.2.0/minimal.c:63: undefined reference to `pcre2_get_error_message_8' collect2: error: ld returned 1 exit status root@samd:/tmp/linuxinfo-3.2.0# echo $? 1 I'm not sure what else I could try. Thanks for any pointers. Greetings Helge -- Dr. Helge Kreutzmann deb...@helgefjell.de Dipl.-Phys. http://www.helgefjell.de/debian.php 64bit GNU powered gpg signed mail preferred Help keep free software "libre": http://www.ffii.de/
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/utsname.h> #include <fcntl.h> #include <ctype.h> #include <sys/types.h> #include <unistd.h> #include <libintl.h> #define _(String) gettext (String) #define PCRE2_CODE_UNIT_WIDTH 8 #include <pcre2.h> static char *models[] = { "K6 \\(166 - 266\\)", "K6", "AMD-K6tm w/ mul", "K6 (MMX)", "K6-2 \\(PR233 - PR333\\)", "K6-2" }; int regstrcmp(const char *subjstring, const char *pstring) { pcre2_code *re; PCRE2_SPTR pattern; /* PCRE2_SPTR is a pointer to unsigned code units of */ PCRE2_SPTR subject; /* the appropriate width (in this case, 8 bits). */ int errornumber; int rc; PCRE2_SIZE erroroffset; size_t subject_length; pcre2_match_data *match_data; /* As pattern and subject are char arguments, they can be straightforwardly cast to PCRE2_SPTR as we are working in 8-bit code units. */ pattern = (PCRE2_SPTR)pstring; subject = (PCRE2_SPTR)subjstring; subject_length = strlen((char *)subject); /************************************************************************* * Now we are going to compile the regular expression pattern, and handle * * any errors that are detected. * *************************************************************************/ re = pcre2_compile( pattern, /* the pattern */ PCRE2_ZERO_TERMINATED, /* indicates pattern is zero-terminated */ 0, /* default options */ &errornumber, /* for error number */ &erroroffset, /* for error offset */ NULL); /* use default compile context */ /* Compilation failed: print the error message and exit. */ /* This should not happen */ if (re == NULL) { PCRE2_UCHAR buffer[256]; pcre2_get_error_message(errornumber, buffer, sizeof(buffer)); printf(_("PCRE2 compilation failed at offset %d: %s\n"), (int)erroroffset,buffer); return 1; } /************************************************************************* * If the compilation succeeded, we call PCRE again, in order to do a * * pattern match against the subject string. This does just ONE match. # * Before running the match we must set up a match_data block for holding * * the result. # *************************************************************************/ /* Using this function ensures that the block is exactly the right size for the number of capturing parentheses in the pattern. */ match_data = pcre2_match_data_create_from_pattern(re, NULL); rc = pcre2_match( re, /* the compiled pattern */ subject, /* the subject string */ subject_length, /* the length of the subject */ 0, /* start at offset 0 in the subject */ 0, /* default options */ match_data, /* block for storing the result */ NULL); /* use default match context */ /* Matching failed: handle error cases */ if (rc < 0) { switch(rc) { // case PCRE2_ERROR_NOMATCH: printf("No match\n"); break; case PCRE2_ERROR_NOMATCH: break; /* Handle other special cases if you like */ default: printf(_("Matching error %d\n"), rc); break; } pcre2_match_data_free(match_data); /* Release memory used for the match */ pcre2_code_free(re); /* data and the compiled pattern. */ return 1; } pcre2_match_data_free(match_data); /* Release the memory that was used */ pcre2_code_free(re); /* for the match data and the pattern. */ return 0; /* Exit the function. */ } int main(int argc, char *argv[]) { char temp_string2[BUFSIZ]; if (regstrcmp(temp_string2, models[3])) { printf("Output"); } }
signature.asc
Description: PGP signature