posix_api_check.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. *
  3. * Copyright (c) 1998-2002
  4. * John Maddock
  5. *
  6. * Use, modification and distribution are subject to the
  7. * Boost Software License, Version 1.0. (See accompanying file
  8. * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. *
  10. */
  11. /*
  12. * LOCATION: see http://www.boost.org for most recent version.
  13. * FILE posix_api_compiler_check.c
  14. * VERSION see <boost/version.hpp>
  15. * DESCRIPTION: Verify that POSIX API calls compile: note this is a compile
  16. * time check only.
  17. */
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include <assert.h>
  21. #include <boost/regex.h>
  22. const char* expression = "^";
  23. const char* text = "\n ";
  24. regmatch_t matches[1];
  25. int flags = REG_EXTENDED | REG_BASIC | REG_NOSPEC | REG_ICASE | REG_NOSUB |
  26. REG_NEWLINE | REG_PEND | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS |
  27. REG_NEWLINE_ALT | REG_PERL | REG_AWK | REG_GREP | REG_EGREP;
  28. int main()
  29. {
  30. regex_tA re;
  31. int result;
  32. result = regcompA(&re, expression, REG_AWK);
  33. if(result > (int)REG_NOERROR)
  34. {
  35. char buf[256];
  36. regerrorA(result, &re, buf, sizeof(buf));
  37. puts(buf);
  38. return result;
  39. }
  40. assert(re.re_nsub == 0);
  41. matches[0].rm_so = 0;
  42. matches[0].rm_eo = strlen(text);
  43. result = regexecA(&re, text, 1, matches, REG_NOTBOL | REG_NOTEOL | REG_STARTEND);
  44. if(result > (int)REG_NOERROR)
  45. {
  46. char buf[256];
  47. regerrorA(result, &re, buf, sizeof(buf));
  48. puts(buf);
  49. regfreeA(&re);
  50. return result;
  51. }
  52. assert((matches[0].rm_so == matches[0].rm_eo) && (matches[0].rm_eo == 1));
  53. regfreeA(&re);
  54. printf("no errors found\n");
  55. return 0;
  56. }