posix_api_check.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 <boost/assert.hpp>
  21. #include <boost/regex.h>
  22. #include "../test_macros.hpp"
  23. const char* expression = "^";
  24. const char* text = "\n ";
  25. regmatch_t matches[1];
  26. int flags = REG_EXTENDED | REG_BASIC | REG_NOSPEC | REG_ICASE | REG_NOSUB |
  27. REG_NEWLINE | REG_PEND | REG_NOCOLLATE | REG_ESCAPE_IN_LISTS |
  28. REG_NEWLINE_ALT | REG_PERL | REG_AWK | REG_GREP | REG_EGREP;
  29. int main()
  30. {
  31. regex_tA re;
  32. unsigned int result;
  33. result = regcompA(&re, expression, REG_AWK);
  34. if(result > REG_NOERROR)
  35. {
  36. char buf[256];
  37. regerrorA(result, &re, buf, sizeof(buf));
  38. printf("%s", buf);
  39. return result;
  40. }
  41. BOOST_CHECK(re.re_nsub == 0);
  42. matches[0].rm_so = 0;
  43. matches[0].rm_eo = strlen(text);
  44. result = regexecA(&re, text, 1, matches, REG_NOTBOL | REG_NOTEOL | REG_STARTEND);
  45. if(result > REG_NOERROR)
  46. {
  47. char buf[256];
  48. regerrorA(result, &re, buf, sizeof(buf));
  49. printf("%s", buf);
  50. regfreeA(&re);
  51. return result;
  52. }
  53. BOOST_CHECK(matches[0].rm_so == matches[0].rm_eo);
  54. regfreeA(&re);
  55. printf("no errors found\n");
  56. return boost::report_errors();
  57. }