Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid invoking regex on win32 #3

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI Build

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:
strategy:
matrix:
platform:
- ubuntu-latest
- macos-latest
- windows-latest

runs-on: ${{ matrix.platform }}

steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Build
run: |
mkdir build
cd build
cmake ..
cmake --build .
22 changes: 19 additions & 3 deletions git-xdiff.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <regex.h>

/* Work around C90-conformance issues */
#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
Expand Down Expand Up @@ -47,8 +46,23 @@

#define XDL_BUG(msg) do { fprintf(stderr, "fatal: %s\n", msg); exit(128); } while(0)

#define xdl_regex_t regex_t
#define xdl_regmatch_t regmatch_t
#if defined(_MSC_VER) && !defined(XDL_REGEX)

# define xdl_regex_t void *
# define xdl_regmatch_t void *

inline int xdl_regexec_buf(
const xdl_regex_t *preg, const char *buf, size_t size,
size_t nmatch, xdl_regmatch_t pmatch[], int eflags)
{
return 15; /* REG_ASSERT */
}

#else
# include <regex.h>

# define xdl_regex_t regex_t
# define xdl_regmatch_t regmatch_t

inline int xdl_regexec_buf(
const xdl_regex_t *preg, const char *buf, size_t size,
Expand All @@ -60,4 +74,6 @@ inline int xdl_regexec_buf(
return regexec(preg, buf, nmatch, pmatch, eflags | REG_STARTEND);
}

#endif /* XDL_NO_REGEX */

#endif