v0.2.1 c0399be

gregex.go RawHistoryFolder

1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5	"structs"
6	"unsafe"
7
8	"github.com/ebitengine/purego"
9
10	"github.com/bnema/puregotk/pkg/core"
11	"github.com/bnema/puregotk/v4/gobject/types"
12)
13
14// Specifies the type of the function passed to g_regex_replace_eval().
15// It is called for each occurrence of the pattern in the string passed
16// to g_regex_replace_eval(), and it should append the replacement to
17// @result.
18type RegexEvalCallback func(*MatchInfo, *String, uintptr) bool
19
20// A GMatchInfo is an opaque struct used to return information about
21// matches.
22type MatchInfo struct {
23	_ structs.HostLayout
24}
25
26var xMatchInfoGLibType func() types.GType
27
28func MatchInfoGLibType() types.GType {
29	return xMatchInfoGLibType()
30}
31
32func (x *MatchInfo) GoPointer() uintptr {
33	return uintptr(unsafe.Pointer(x))
34}
35
36var xMatchInfoExpandReferences func(uintptr, string, **Error) string
37
38// Returns a new string containing the text in @string_to_expand with
39// references and escape sequences expanded. References refer to the last
40// match done with @string against @regex and have the same syntax used by
41// g_regex_replace().
42//
43// The @string_to_expand must be UTF-8 encoded even if %G_REGEX_RAW was
44// passed to g_regex_new().
45//
46// The backreferences are extracted from the string passed to the match
47// function, so you cannot call this function after freeing the string.
48//
49// @match_info may be %NULL in which case @string_to_expand must not
50// contain references. For instance "foo\n" does not refer to an actual
51// pattern and '\n' merely will be replaced with \n character,
52// while to expand "\0" (whole match) one needs the result of a match.
53// Use g_regex_check_replacement() to find out whether @string_to_expand
54// contains references.
55func (x *MatchInfo) ExpandReferences(StringToExpandVar string) (string, error) {
56	var cerr *Error
57
58	cret := xMatchInfoExpandReferences(x.GoPointer(), StringToExpandVar, &cerr)
59	if cerr == nil {
60		return cret, nil
61	}
62	return cret, cerr
63
64}
65
66var xMatchInfoFetch func(uintptr, int) string
67
68// Retrieves the text matching the @match_num'th capturing
69// parentheses. 0 is the full text of the match, 1 is the first paren
70// set, 2 the second, and so on.
71//
72// If @match_num is a valid sub pattern but it didn't match anything
73// (e.g. sub pattern 1, matching "b" against "(a)?b") then an empty
74// string is returned.
75//
76// If the match was obtained using the DFA algorithm, that is using
77// g_regex_match_all() or g_regex_match_all_full(), the retrieved
78// string is not that of a set of parentheses but that of a matched
79// substring. Substrings are matched in reverse order of length, so
80// 0 is the longest match.
81//
82// The string is fetched from the string passed to the match function,
83// so you cannot call this function after freeing the string.
84func (x *MatchInfo) Fetch(MatchNumVar int) string {
85
86	cret := xMatchInfoFetch(x.GoPointer(), MatchNumVar)
87	return cret
88}
89
90var xMatchInfoFetchAll func(uintptr) []string
91
92// Bundles up pointers to each of the matching substrings from a match
93// and stores them in an array of gchar pointers. The first element in
94// the returned array is the match number 0, i.e. the entire matched
95// text.
96//
97// If a sub pattern didn't match anything (e.g. sub pattern 1, matching
98// "b" against "(a)?b") then an empty string is inserted.
99//
100// If the last match was obtained using the DFA algorithm, that is using
101// g_regex_match_all() or g_regex_match_all_full(), the retrieved
102// strings are not that matched by sets of parentheses but that of the
103// matched substring. Substrings are matched in reverse order of length,
104// so the first one is the longest match.
105//
106// The strings are fetched from the string passed to the match function,
107// so you cannot call this function after freeing the string.
108func (x *MatchInfo) FetchAll() []string {
109
110	cret := xMatchInfoFetchAll(x.GoPointer())
111	return cret
112}
113
114var xMatchInfoFetchNamed func(uintptr, string) string
115
116// Retrieves the text matching the capturing parentheses named @name.
117//
118// If @name is a valid sub pattern name but it didn't match anything
119// (e.g. sub pattern `"X"`, matching `"b"` against `"(?P<X>a)?b"`)
120// then an empty string is returned.
121//
122// The string is fetched from the string passed to the match function,
123// so you cannot call this function after freeing the string.
124func (x *MatchInfo) FetchNamed(NameVar string) string {
125
126	cret := xMatchInfoFetchNamed(x.GoPointer(), NameVar)
127	return cret
128}
129
130var xMatchInfoFetchNamedPos func(uintptr, string, *int, *int) bool
131
132// Retrieves the position in bytes of the capturing parentheses named @name.
133//
134// If @name is a valid sub pattern name but it didn't match anything
135// (e.g. sub pattern `"X"`, matching `"b"` against `"(?P<X>a)?b"`)
136// then @start_pos and @end_pos are set to -1 and %TRUE is returned.
137//
138// As @end_pos is set to the byte after the final byte of the match (on success),
139// the length of the match can be calculated as `end_pos - start_pos`.
140func (x *MatchInfo) FetchNamedPos(NameVar string, StartPosVar *int, EndPosVar *int) bool {
141
142	cret := xMatchInfoFetchNamedPos(x.GoPointer(), NameVar, StartPosVar, EndPosVar)
143	return cret
144}
145
146var xMatchInfoFetchPos func(uintptr, int, *int, *int) bool
147
148// Returns the start and end positions (in bytes) of a successfully matching
149// capture parenthesis.
150//
151// Valid values for @match_num are `0` for the full text of the match,
152// `1` for the first paren set, `2` for the second, and so on.
153//
154// As @end_pos is set to the byte after the final byte of the match (on success),
155// the length of the match can be calculated as `end_pos - start_pos`.
156//
157// As a best practice, initialize @start_pos and @end_pos to identifiable
158// values, such as `G_MAXINT`, so that you can test if
159// `g_match_info_fetch_pos()` actually changed the value for a given
160// capture parenthesis.
161//
162// The parameter @match_num corresponds to a matched capture parenthesis. The
163// actual value you use for @match_num depends on the method used to generate
164// @match_info. The following sections describe those methods.
165//
166// ## Methods Using Non-deterministic Finite Automata Matching
167//
168// The methods [method@GLib.Regex.match] and [method@GLib.Regex.match_full]
169// return a [struct@GLib.MatchInfo] using traditional (greedy) pattern
170// matching, also known as
171// [Non-deterministic Finite Automaton](https://en.wikipedia.org/wiki/Nondeterministic_finite_automaton)
172// (NFA) matching. You pass the returned `GMatchInfo` from these methods to
173// `g_match_info_fetch_pos()` to determine the start and end positions
174// of capture parentheses. The values for @match_num correspond to the capture
175// parentheses in order, with `0` corresponding to the entire matched string.
176//
177// @match_num can refer to a capture parenthesis with no match. For example,
178// the string `b` matches against the pattern `(a)?b`, but the capture
179// parenthesis `(a)` has no match. In this case, `g_match_info_fetch_pos()`
180// returns true and sets @start_pos and @end_pos to `-1` when called with
181// `match_num` as `1` (for `(a)`).
182//
183// For an expanded example, a regex pattern is `(a)?(.*?)the (.*)`,
184// and a candidate string is `glib regexes are the best`. In this scenario
185// there are four capture parentheses numbered 0–3: an implicit one
186// for the entire string, and three explicitly declared in the regex pattern.
187//
188// Given this example, the following table describes the return values
189// from `g_match_info_fetch_pos()` for various values of @match_num.
190//
191// `match_num` | Contents | Return value | Returned `start_pos` | Returned `end_pos`
192// ----------- | -------- | ------------ | -------------------- | ------------------
193// 0 | Matches entire string | True | 0 | 25
194// 1 | Does not match first character | True | -1 | -1
195// 2 | All text before `the ` | True | 0 | 17
196// 3 | All text after `the ` | True | 21 | 25
197// 4 | Capture paren out of range | False | Unchanged | Unchanged
198//
199// The following code sample and output implements this example.
200//
201// ``` { .c }
202// #include <glib.h>
203//
204// int
205// main (int argc, char *argv[])
206//
207//	{
208//	  g_autoptr(GError) local_error = NULL;
209//	  const char *regex_pattern = "(a)?(.*?)the (.*)";
210//	  const char *test_string = "glib regexes are the best";
211//	  g_autoptr(GRegex) regex = NULL;
212//
213//	  regex = g_regex_new (regex_pattern,
214//	                       G_REGEX_DEFAULT,
215//	                       G_REGEX_MATCH_DEFAULT,
216//	                       &local_error);
217//	  if (regex == NULL)
218//	    {
219//	      g_printerr ("Error creating regex: %s\n", local_error->message);
220//	      return 1;
221//	    }
222//
223//	  g_autoptr(GMatchInfo) match_info = NULL;
224//	  g_regex_match (regex, test_string, G_REGEX_MATCH_DEFAULT, &match_info);
225//
226//	  int n_matched_strings = g_match_info_get_match_count (match_info);
227//
228//	  // Print header line
229//	  g_print ("match_num Contents                  Return value returned start_pos returned end_pos\n");
230//
231//	  // Iterate over each capture paren, including one that is out of range as a demonstration.
232//	  for (int match_num = 0; match_num <= n_matched_strings; match_num++)
233//	    {
234//	      gboolean found_match;
235//	      g_autofree char *paren_string = NULL;
236//	      int start_pos = G_MAXINT;
237//	      int end_pos = G_MAXINT;
238//
239//	      found_match = g_match_info_fetch_pos (match_info,
240//	                                            match_num,
241//	                                            &start_pos,
242//	                                            &end_pos);
243//
244//	      // If no match, display N/A as the found string.
245//	      if (start_pos == G_MAXINT || start_pos == -1)
246//	        paren_string = g_strdup ("N/A");
247//	      else
248//	        paren_string = g_strndup (test_string + start_pos, end_pos - start_pos);
249//
250//	      g_print ("%-9d %-25s %-12d %-18d %d\n", match_num, paren_string, found_match, start_pos, end_pos);
251//	    }
252//
253//	  return 0;
254//	}
255//
256// ```
257//
258// ```
259// match_num Contents                  Return value returned start_pos returned end_pos
260// 0         glib regexes are the best 1            0                  25
261// 1         N/A                       1            -1                 -1
262// 2         glib regexes are          1            0                  17
263// 3         best                      1            21                 25
264// 4         N/A                       0            2147483647         2147483647
265// ```
266// ## Methods Using Deterministic Finite Automata Matching
267//
268// The methods [method@GLib.Regex.match_all] and
269// [method@GLib.Regex.match_all_full]
270// return a `GMatchInfo` using
271// [Deterministic Finite Automaton](https://en.wikipedia.org/wiki/Deterministic_finite_automaton)
272// (DFA) pattern matching. This algorithm detects overlapping matches. You pass
273// the returned `GMatchInfo` from these methods to `g_match_info_fetch_pos()`
274// to determine the start and end positions of each overlapping match. Use the
275// method [method@GLib.MatchInfo.get_match_count] to determine the number
276// of overlapping matches.
277//
278// For example, a regex pattern is `<.*>`, and a candidate string is
279// `<a> <b> <c>`. In this scenario there are three implicit capture
280// parentheses: one for the entire string, one for `<a> <b>`, and one for `<a>`.
281//
282// Given this example, the following table describes the return values from
283// `g_match_info_fetch_pos()` for various values of @match_num.
284//
285// `match_num` | Contents | Return value | Returned `start_pos` | Returned `end_pos`
286// ----------- | -------- | ------------ | -------------------- | ------------------
287// 0 | Matches entire string | True | 0 | 11
288// 1 | Matches `<a> <b>` | True | 0 | 7
289// 2 | Matches `<a>` | True | 0 | 3
290// 3 | Capture paren out of range | False | Unchanged | Unchanged
291//
292// The following code sample and output implements this example.
293//
294// ``` { .c }
295// #include <glib.h>
296//
297// int
298// main (int argc, char *argv[])
299//
300//	{
301//	  g_autoptr(GError) local_error = NULL;
302//	  const char *regex_pattern = "<.*>";
303//	  const char *test_string = "<a> <b> <c>";
304//	  g_autoptr(GRegex) regex = NULL;
305//
306//	  regex = g_regex_new (regex_pattern,
307//	                       G_REGEX_DEFAULT,
308//	                       G_REGEX_MATCH_DEFAULT,
309//	                       &local_error);
310//	  if (regex == NULL)
311//	    {
312//	      g_printerr ("Error creating regex: %s\n", local_error->message);
313//	      return -1;
314//	    }
315//
316//	  g_autoptr(GMatchInfo) match_info = NULL;
317//	  g_regex_match_all (regex, test_string, G_REGEX_MATCH_DEFAULT, &match_info);
318//
319//	  int n_matched_strings = g_match_info_get_match_count (match_info);
320//
321//	  // Print header line
322//	  g_print ("match_num Contents                  Return value returned start_pos returned end_pos\n");
323//
324//	  // Iterate over each capture paren, including one that is out of range as a demonstration.
325//	  for (int match_num = 0; match_num <= n_matched_strings; match_num++)
326//	    {
327//	      gboolean found_match;
328//	      g_autofree char *paren_string = NULL;
329//	      int start_pos = G_MAXINT;
330//	      int end_pos = G_MAXINT;
331//
332//	      found_match = g_match_info_fetch_pos (match_info, match_num, &start_pos, &end_pos);
333//
334//	      // If no match, display N/A as the found string.
335//	      if (start_pos == G_MAXINT || start_pos == -1)
336//	        paren_string = g_strdup ("N/A");
337//	      else
338//	        paren_string = g_strndup (test_string + start_pos, end_pos - start_pos);
339//
340//	      g_print ("%-9d %-25s %-12d %-18d %d\n", match_num, paren_string, found_match, start_pos, end_pos);
341//	    }
342//
343//	  return 0;
344//	}
345//
346// ```
347//
348// ```
349// match_num Contents                  Return value returned start_pos returned end_pos
350// 0         <a> <b> <c>               1            0                  11
351// 1         <a> <b>                   1            0                  7
352// 2         <a>                       1            0                  3
353// 3         N/A                       0            2147483647         2147483647
354// ```
355func (x *MatchInfo) FetchPos(MatchNumVar int, StartPosVar *int, EndPosVar *int) bool {
356
357	cret := xMatchInfoFetchPos(x.GoPointer(), MatchNumVar, StartPosVar, EndPosVar)
358	return cret
359}
360
361var xMatchInfoFree func(uintptr)
362
363// If @match_info is not %NULL, calls g_match_info_unref(); otherwise does
364// nothing.
365func (x *MatchInfo) Free() {
366
367	xMatchInfoFree(x.GoPointer())
368
369}
370
371var xMatchInfoGetMatchCount func(uintptr) int
372
373// Retrieves the number of matched substrings (including substring 0,
374// that is the whole matched text), so 1 is returned if the pattern
375// has no substrings in it and 0 is returned if the match failed.
376//
377// If the last match was obtained using the DFA algorithm, that is
378// using g_regex_match_all() or g_regex_match_all_full(), the retrieved
379// count is not that of the number of capturing parentheses but that of
380// the number of matched substrings.
381func (x *MatchInfo) GetMatchCount() int {
382
383	cret := xMatchInfoGetMatchCount(x.GoPointer())
384	return cret
385}
386
387var xMatchInfoGetRegex func(uintptr) *Regex
388
389// Returns #GRegex object used in @match_info. It belongs to Glib
390// and must not be freed. Use g_regex_ref() if you need to keep it
391// after you free @match_info object.
392func (x *MatchInfo) GetRegex() *Regex {
393
394	cret := xMatchInfoGetRegex(x.GoPointer())
395	return cret
396}
397
398var xMatchInfoGetString func(uintptr) string
399
400// Returns the string searched with @match_info. This is the
401// string passed to g_regex_match() or g_regex_replace() so
402// you may not free it before calling this function.
403func (x *MatchInfo) GetString() string {
404
405	cret := xMatchInfoGetString(x.GoPointer())
406	return cret
407}
408
409var xMatchInfoIsPartialMatch func(uintptr) bool
410
411// Usually if the string passed to g_regex_match*() matches as far as
412// it goes, but is too short to match the entire pattern, %FALSE is
413// returned. There are circumstances where it might be helpful to
414// distinguish this case from other cases in which there is no match.
415//
416// Consider, for example, an application where a human is required to
417// type in data for a field with specific formatting requirements. An
418// example might be a date in the form ddmmmyy, defined by the pattern
419// "^\d?\d(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d\d$".
420// If the application sees the user’s keystrokes one by one, and can
421// check that what has been typed so far is potentially valid, it is
422// able to raise an error as soon as a mistake is made.
423//
424// GRegex supports the concept of partial matching by means of the
425// %G_REGEX_MATCH_PARTIAL_SOFT and %G_REGEX_MATCH_PARTIAL_HARD flags.
426// When they are used, the return code for
427// g_regex_match() or g_regex_match_full() is, as usual, %TRUE
428// for a complete match, %FALSE otherwise. But, when these functions
429// return %FALSE, you can check if the match was partial calling
430// g_match_info_is_partial_match().
431//
432// The difference between %G_REGEX_MATCH_PARTIAL_SOFT and
433// %G_REGEX_MATCH_PARTIAL_HARD is that when a partial match is encountered
434// with %G_REGEX_MATCH_PARTIAL_SOFT, matching continues to search for a
435// possible complete match, while with %G_REGEX_MATCH_PARTIAL_HARD matching
436// stops at the partial match.
437// When both %G_REGEX_MATCH_PARTIAL_SOFT and %G_REGEX_MATCH_PARTIAL_HARD
438// are set, the latter takes precedence.
439//
440// There were formerly some restrictions on the pattern for partial matching.
441// The restrictions no longer apply.
442//
443// See pcrepartial(3) for more information on partial matching.
444func (x *MatchInfo) IsPartialMatch() bool {
445
446	cret := xMatchInfoIsPartialMatch(x.GoPointer())
447	return cret
448}
449
450var xMatchInfoMatches func(uintptr) bool
451
452// Returns whether the previous match operation succeeded.
453func (x *MatchInfo) Matches() bool {
454
455	cret := xMatchInfoMatches(x.GoPointer())
456	return cret
457}
458
459var xMatchInfoNext func(uintptr) bool
460
461// Scans for the next match using the same parameters of the previous
462// call to g_regex_match_full() or g_regex_match() that returned
463// @match_info.
464//
465// The match is done on the string passed to the match function, so you
466// cannot free it before calling this function.
467func (x *MatchInfo) Next() (bool, error) {
468	var cerr *Error
469
470	cret := xMatchInfoNext(x.GoPointer())
471	if cerr == nil {
472		return cret, nil
473	}
474	return cret, cerr
475
476}
477
478var xMatchInfoRef func(uintptr) *MatchInfo
479
480// Increases reference count of @match_info by 1.
481func (x *MatchInfo) Ref() *MatchInfo {
482
483	cret := xMatchInfoRef(x.GoPointer())
484	return cret
485}
486
487var xMatchInfoUnref func(uintptr)
488
489// Decreases reference count of @match_info by 1. When reference count drops
490// to zero, it frees all the memory associated with the match_info structure.
491func (x *MatchInfo) Unref() {
492
493	xMatchInfoUnref(x.GoPointer())
494
495}
496
497// A `GRegex` is a compiled form of a regular expression.
498//
499// After instantiating a `GRegex`, you can use its methods to find matches
500// in a string, replace matches within a string, or split the string at matches.
501//
502// `GRegex` implements regular expression pattern matching using syntax and
503// semantics (such as character classes, quantifiers, and capture groups)
504// similar to Perl regular expression. See the
505// [PCRE documentation](man:pcre2pattern(3)) for details.
506//
507// A typical scenario for regex pattern matching is to check if a string
508// matches a pattern. The following statements implement this scenario.
509//
510// ``` { .c }
511// const char *regex_pattern = ".*GLib.*";
512// const char *string_to_search = "You will love the GLib implementation of regex";
513// g_autoptr(GMatchInfo) match_info = NULL;
514// g_autoptr(GRegex) regex = NULL;
515//
516// regex = g_regex_new (regex_pattern, G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
517// g_assert (regex != NULL);
518//
519// if (g_regex_match (regex, string_to_search, G_REGEX_MATCH_DEFAULT, &match_info))
520//
521//	{
522//	  int start_pos, end_pos;
523//	  g_match_info_fetch_pos (match_info, 0, &start_pos, &end_pos);
524//	  g_print ("Match successful! Overall pattern matches bytes %d to %d\n", start_pos, end_pos);
525//	}
526//
527// else
528//
529//	{
530//	  g_print ("No match!\n");
531//	}
532//
533// ```
534//
535// The constructor for `GRegex` includes two sets of bitmapped flags:
536//
537// * [flags@GLib.RegexCompileFlags]—These flags
538// control how GLib compiles the regex. There are options for case
539// sensitivity, multiline, ignoring whitespace, etc.
540// * [flags@GLib.RegexMatchFlags]—These flags control
541// `GRegex`’s matching behavior, such as anchoring and customizing definitions
542// for newline characters.
543//
544// Some regex patterns include backslash assertions, such as `\d` (digit) or
545// `\D` (non-digit). The regex pattern must escape those backslashes. For
546// example, the pattern `"\\d\\D"` matches a digit followed by a non-digit.
547//
548// GLib’s implementation of pattern matching includes a `start_position`
549// argument for some of the match, replace, and split methods. Specifying
550// a start position provides flexibility when you want to ignore the first
551// _n_ characters of a string, but want to incorporate backslash assertions
552// at character _n_ - 1. For example, a database field contains inconsistent
553// spelling for a job title: `healthcare provider` and `health-care provider`.
554// The database manager wants to make the spelling consistent by adding a
555// hyphen when it is missing. The following regex pattern tests for the string
556// `care` preceded by a non-word boundary character (instead of a hyphen)
557// and followed by a space.
558//
559// ``` { .c }
560// const char *regex_pattern = "\\Bcare\\s";
561// ```
562//
563// An efficient way to match with this pattern is to start examining at
564// `start_position` 6 in the string `healthcare` or `health-care`.
565//
566// ``` { .c }
567// const char *regex_pattern = "\\Bcare\\s";
568// const char *string_to_search = "healthcare provider";
569// g_autoptr(GMatchInfo) match_info = NULL;
570// g_autoptr(GRegex) regex = NULL;
571//
572// regex = g_regex_new (
573//
574//	regex_pattern,
575//	G_REGEX_DEFAULT,
576//	G_REGEX_MATCH_DEFAULT,
577//	NULL);
578//
579// g_assert (regex != NULL);
580//
581// g_regex_match_full (
582//
583//	regex,
584//	string_to_search,
585//	-1,
586//	6, // position of 'c' in the test string.
587//	G_REGEX_MATCH_DEFAULT,
588//	&match_info,
589//	NULL);
590//
591// ```
592//
593// The method [method@GLib.Regex.match_full] (and other methods implementing
594// `start_pos`) allow for lookback before the start position to determine if
595// the previous character satisfies an assertion.
596//
597// Unless you set the [flags@GLib.RegexCompileFlags.RAW] as one of
598// the `GRegexCompileFlags`, all the strings passed to `GRegex` methods must
599// be encoded in UTF-8. The lengths and the positions inside the strings are
600// in bytes and not in characters, so, for instance, `\xc3\xa0` (i.e., `à`)
601// is two bytes long but it is treated as a single character. If you set
602// `G_REGEX_RAW`, the strings can be non-valid UTF-8 strings and a byte is
603// treated as a character, so `\xc3\xa0` is two bytes and two characters long.
604//
605// Regarding line endings, `\n` matches a `\n` character, and `\r` matches
606// a `\r` character. More generally, `\R` matches all typical line endings:
607// CR + LF (`\r\n`), LF (linefeed, U+000A, `\n`), VT (vertical tab, U+000B,
608// `\v`), FF (formfeed, U+000C, `\f`), CR (carriage return, U+000D, `\r`),
609// NEL (next line, U+0085), LS (line separator, U+2028), and PS (paragraph
610// separator, U+2029).
611//
612// The behaviour of the dot, circumflex, and dollar metacharacters are
613// affected by newline characters. By default, `GRegex` matches any newline
614// character matched by `\R`. You can limit the matched newline characters by
615// specifying the [flags@GLib.RegexMatchFlags.NEWLINE_CR],
616// [flags@GLib.RegexMatchFlags.NEWLINE_LF], and
617// [flags@GLib.RegexMatchFlags.NEWLINE_CRLF] compile options, and
618// with [flags@GLib.RegexMatchFlags.NEWLINE_ANY],
619// [flags@GLib.RegexMatchFlags.NEWLINE_CR],
620// [flags@GLib.RegexMatchFlags.NEWLINE_LF] and
621// [flags@GLib.RegexMatchFlags.NEWLINE_CRLF] match options.
622// These settings are also relevant when compiling a pattern if
623// [flags@GLib.RegexCompileFlags.EXTENDED] is set and an unescaped
624// `#` outside a character class is encountered. This indicates a comment
625// that lasts until after the next newline.
626//
627// Because `GRegex` does not modify its internal state between creation and
628// destruction, you can create and modify the same `GRegex` instance from
629// different threads. In contrast, [struct@GLib.MatchInfo] is not thread safe.
630//
631// The regular expression low-level functionalities are obtained through
632// the excellent [PCRE](http://www.pcre.org/) library written by Philip Hazel.
633type Regex struct {
634	_ structs.HostLayout
635}
636
637var xRegexGLibType func() types.GType
638
639func RegexGLibType() types.GType {
640	return xRegexGLibType()
641}
642
643func (x *Regex) GoPointer() uintptr {
644	return uintptr(unsafe.Pointer(x))
645}
646
647var xNewRegex func(string, RegexCompileFlags, RegexMatchFlags, **Error) *Regex
648
649// Compiles the regular expression to an internal form, and does
650// the initial setup of the #GRegex structure.
651func NewRegex(PatternVar string, CompileOptionsVar RegexCompileFlags, MatchOptionsVar RegexMatchFlags) (*Regex, error) {
652	var cerr *Error
653
654	cret := xNewRegex(PatternVar, CompileOptionsVar, MatchOptionsVar, &cerr)
655	if cerr == nil {
656		return cret, nil
657	}
658	return cret, cerr
659
660}
661
662var xRegexGetCaptureCount func(uintptr) int
663
664// Returns the number of capturing subpatterns in the pattern.
665func (x *Regex) GetCaptureCount() int {
666
667	cret := xRegexGetCaptureCount(x.GoPointer())
668	return cret
669}
670
671var xRegexGetCompileFlags func(uintptr) RegexCompileFlags
672
673// Returns the compile options that @regex was created with.
674//
675// Depending on the version of PCRE that is used, this may or may not
676// include flags set by option expressions such as `(?i)` found at the
677// top-level within the compiled pattern.
678func (x *Regex) GetCompileFlags() RegexCompileFlags {
679
680	cret := xRegexGetCompileFlags(x.GoPointer())
681	return cret
682}
683
684var xRegexGetHasCrOrLf func(uintptr) bool
685
686// Checks whether the pattern contains explicit CR or LF references.
687func (x *Regex) GetHasCrOrLf() bool {
688
689	cret := xRegexGetHasCrOrLf(x.GoPointer())
690	return cret
691}
692
693var xRegexGetMatchFlags func(uintptr) RegexMatchFlags
694
695// Returns the match options that @regex was created with.
696func (x *Regex) GetMatchFlags() RegexMatchFlags {
697
698	cret := xRegexGetMatchFlags(x.GoPointer())
699	return cret
700}
701
702var xRegexGetMaxBackref func(uintptr) int
703
704// Returns the number of the highest back reference
705// in the pattern, or 0 if the pattern does not contain
706// back references.
707func (x *Regex) GetMaxBackref() int {
708
709	cret := xRegexGetMaxBackref(x.GoPointer())
710	return cret
711}
712
713var xRegexGetMaxLookbehind func(uintptr) int
714
715// Gets the number of characters in the longest lookbehind assertion in the
716// pattern. This information is useful when doing multi-segment matching using
717// the partial matching facilities.
718func (x *Regex) GetMaxLookbehind() int {
719
720	cret := xRegexGetMaxLookbehind(x.GoPointer())
721	return cret
722}
723
724var xRegexGetPattern func(uintptr) string
725
726// Gets the pattern string associated with @regex, i.e. a copy of
727// the string passed to g_regex_new().
728func (x *Regex) GetPattern() string {
729
730	cret := xRegexGetPattern(x.GoPointer())
731	return cret
732}
733
734var xRegexGetStringNumber func(uintptr, string) int
735
736// Retrieves the number of the subexpression named @name.
737func (x *Regex) GetStringNumber(NameVar string) int {
738
739	cret := xRegexGetStringNumber(x.GoPointer(), NameVar)
740	return cret
741}
742
743var xRegexMatch func(uintptr, string, RegexMatchFlags, **MatchInfo) bool
744
745// Scans for a match in @string for the pattern in @regex.
746// The @match_options are combined with the match options specified
747// when the @regex structure was created, letting you have more
748// flexibility in reusing #GRegex structures.
749//
750// Unless %G_REGEX_RAW is specified in the options, @string must be valid UTF-8.
751//
752// A #GMatchInfo structure, used to get information on the match,
753// is stored in @match_info if not %NULL. Note that if @match_info
754// is not %NULL then it is created even if the function returns %FALSE,
755// i.e. you must free it regardless if regular expression actually matched.
756//
757// To retrieve all the non-overlapping matches of the pattern in
758// string you can use g_match_info_next().
759//
760// |[<!-- language="C" -->
761// static void
762// print_uppercase_words (const gchar *string)
763//
764//	{
765//	  // Print all uppercase-only words.
766//	  GRegex *regex;
767//	  GMatchInfo *match_info;
768//
769//	  regex = g_regex_new ("[A-Z]+", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
770//	  g_regex_match (regex, string, 0, &match_info);
771//	  while (g_match_info_matches (match_info))
772//	    {
773//	      gchar *word = g_match_info_fetch (match_info, 0);
774//	      g_print ("Found: %s\n", word);
775//	      g_free (word);
776//	      g_match_info_next (match_info, NULL);
777//	    }
778//	  g_match_info_free (match_info);
779//	  g_regex_unref (regex);
780//	}
781//
782// ]|
783//
784// @string is not copied and is used in #GMatchInfo internally. If
785// you use any #GMatchInfo method (except g_match_info_free()) after
786// freeing or modifying @string then the behaviour is undefined.
787func (x *Regex) Match(StringVar string, MatchOptionsVar RegexMatchFlags, MatchInfoVar **MatchInfo) bool {
788
789	cret := xRegexMatch(x.GoPointer(), StringVar, MatchOptionsVar, MatchInfoVar)
790	return cret
791}
792
793var xRegexMatchAll func(uintptr, string, RegexMatchFlags, **MatchInfo) bool
794
795// Using the standard algorithm for regular expression matching only
796// the longest match in the string is retrieved. This function uses
797// a different algorithm so it can retrieve all the possible matches.
798// For more documentation see g_regex_match_all_full().
799//
800// A #GMatchInfo structure, used to get information on the match, is
801// stored in @match_info if not %NULL. Note that if @match_info is
802// not %NULL then it is created even if the function returns %FALSE,
803// i.e. you must free it regardless if regular expression actually
804// matched.
805//
806// @string is not copied and is used in #GMatchInfo internally. If
807// you use any #GMatchInfo method (except g_match_info_free()) after
808// freeing or modifying @string then the behaviour is undefined.
809func (x *Regex) MatchAll(StringVar string, MatchOptionsVar RegexMatchFlags, MatchInfoVar **MatchInfo) bool {
810
811	cret := xRegexMatchAll(x.GoPointer(), StringVar, MatchOptionsVar, MatchInfoVar)
812	return cret
813}
814
815var xRegexMatchAllFull func(uintptr, []string, int, int, RegexMatchFlags, **MatchInfo, **Error) bool
816
817// Using the standard algorithm for regular expression matching only
818// the longest match in the @string is retrieved, it is not possible
819// to obtain all the available matches. For instance matching
820// `"<a> <b> <c>"` against the pattern `"<.*>"`
821// you get `"<a> <b> <c>"`.
822//
823// This function uses a different algorithm (called DFA, i.e. deterministic
824// finite automaton), so it can retrieve all the possible matches, all
825// starting at the same point in the string. For instance matching
826// `"<a> <b> <c>"` against the pattern `"<.*>"`
827// you would obtain three matches: `"<a> <b> <c>"`,
828// `"<a> <b>"` and `"<a>"`.
829//
830// The number of matched strings is retrieved using
831// g_match_info_get_match_count(). To obtain the matched strings and
832// their position you can use, respectively, g_match_info_fetch() and
833// g_match_info_fetch_pos(). Note that the strings are returned in
834// reverse order of length; that is, the longest matching string is
835// given first.
836//
837// Note that the DFA algorithm is slower than the standard one and it
838// is not able to capture substrings, so backreferences do not work.
839//
840// Setting @start_position differs from just passing over a shortened
841// string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern
842// that begins with any kind of lookbehind assertion, such as "\b".
843//
844// Unless %G_REGEX_RAW is specified in the options, @string must be valid UTF-8.
845//
846// A #GMatchInfo structure, used to get information on the match, is
847// stored in @match_info if not %NULL. Note that if @match_info is
848// not %NULL then it is created even if the function returns %FALSE,
849// i.e. you must free it regardless if regular expression actually
850// matched.
851//
852// @string is not copied and is used in #GMatchInfo internally. If
853// you use any #GMatchInfo method (except g_match_info_free()) after
854// freeing or modifying @string then the behaviour is undefined.
855func (x *Regex) MatchAllFull(StringVar []string, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, MatchInfoVar **MatchInfo) (bool, error) {
856	var cerr *Error
857
858	cret := xRegexMatchAllFull(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, MatchInfoVar, &cerr)
859	if cerr == nil {
860		return cret, nil
861	}
862	return cret, cerr
863
864}
865
866var xRegexMatchFull func(uintptr, []string, int, int, RegexMatchFlags, **MatchInfo, **Error) bool
867
868// Scans for a match in @string for the pattern in @regex.
869// The @match_options are combined with the match options specified
870// when the @regex structure was created, letting you have more
871// flexibility in reusing #GRegex structures.
872//
873// Setting @start_position differs from just passing over a shortened
874// string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern
875// that begins with any kind of lookbehind assertion, such as "\b".
876//
877// Unless %G_REGEX_RAW is specified in the options, @string must be valid UTF-8.
878//
879// A #GMatchInfo structure, used to get information on the match, is
880// stored in @match_info if not %NULL. Note that if @match_info is
881// not %NULL then it is created even if the function returns %FALSE,
882// i.e. you must free it regardless if regular expression actually
883// matched.
884//
885// @string is not copied and is used in #GMatchInfo internally. If
886// you use any #GMatchInfo method (except g_match_info_free()) after
887// freeing or modifying @string then the behaviour is undefined.
888//
889// To retrieve all the non-overlapping matches of the pattern in
890// string you can use g_match_info_next().
891//
892// |[<!-- language="C" -->
893// static void
894// print_uppercase_words (const gchar *string)
895//
896//	{
897//	  // Print all uppercase-only words.
898//	  GRegex *regex;
899//	  GMatchInfo *match_info;
900//	  GError *error = NULL;
901//
902//	  regex = g_regex_new ("[A-Z]+", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
903//	  g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
904//	  while (g_match_info_matches (match_info))
905//	    {
906//	      gchar *word = g_match_info_fetch (match_info, 0);
907//	      g_print ("Found: %s\n", word);
908//	      g_free (word);
909//	      g_match_info_next (match_info, &error);
910//	    }
911//	  g_match_info_free (match_info);
912//	  g_regex_unref (regex);
913//	  if (error != NULL)
914//	    {
915//	      g_printerr ("Error while matching: %s\n", error->message);
916//	      g_error_free (error);
917//	    }
918//	}
919//
920// ]|
921func (x *Regex) MatchFull(StringVar []string, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, MatchInfoVar **MatchInfo) (bool, error) {
922	var cerr *Error
923
924	cret := xRegexMatchFull(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, MatchInfoVar, &cerr)
925	if cerr == nil {
926		return cret, nil
927	}
928	return cret, cerr
929
930}
931
932var xRegexRef func(uintptr) *Regex
933
934// Increases reference count of @regex by 1.
935func (x *Regex) Ref() *Regex {
936
937	cret := xRegexRef(x.GoPointer())
938	return cret
939}
940
941var xRegexReplace func(uintptr, []string, int, int, string, RegexMatchFlags, **Error) string
942
943// Replaces all occurrences of the pattern in @regex with the
944// replacement text. Backreferences of the form `\number` or
945// `\g<number>` in the replacement text are interpolated by the
946// number-th captured subexpression of the match, `\g<name>` refers
947// to the captured subexpression with the given name. `\0` refers
948// to the complete match, but `\0` followed by a number is the octal
949// representation of a character. To include a literal `\` in the
950// replacement, write `\\\\`.
951//
952// There are also escapes that changes the case of the following text:
953//
954// - \l: Convert to lower case the next character
955// - \u: Convert to upper case the next character
956// - \L: Convert to lower case till \E
957// - \U: Convert to upper case till \E
958// - \E: End case modification
959//
960// If you do not need to use backreferences use g_regex_replace_literal().
961//
962// The @replacement string must be UTF-8 encoded even if %G_REGEX_RAW was
963// passed to g_regex_new(). If you want to use not UTF-8 encoded strings
964// you can use g_regex_replace_literal().
965//
966// Setting @start_position differs from just passing over a shortened
967// string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern that
968// begins with any kind of lookbehind assertion, such as "\b".
969func (x *Regex) Replace(StringVar []string, StringLenVar int, StartPositionVar int, ReplacementVar string, MatchOptionsVar RegexMatchFlags) (string, error) {
970	var cerr *Error
971
972	cret := xRegexReplace(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, ReplacementVar, MatchOptionsVar, &cerr)
973	if cerr == nil {
974		return cret, nil
975	}
976	return cret, cerr
977
978}
979
980var xRegexReplaceEval func(uintptr, []string, int, int, RegexMatchFlags, uintptr, uintptr, **Error) string
981
982// Replaces occurrences of the pattern in regex with the output of
983// @eval for that occurrence.
984//
985// Setting @start_position differs from just passing over a shortened
986// string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern
987// that begins with any kind of lookbehind assertion, such as "\b".
988//
989// The following example uses g_regex_replace_eval() to replace multiple
990// strings at once:
991// |[<!-- language="C" -->
992// static gboolean
993// eval_cb (const GMatchInfo *info,
994//
995//	GString          *res,
996//	gpointer          data)
997//
998//	{
999//	  gchar *match;
1000//	  gchar *r;
1001//
1002//	   match = g_match_info_fetch (info, 0);
1003//	   r = g_hash_table_lookup ((GHashTable *)data, match);
1004//	   g_string_append (res, r);
1005//	   g_free (match);
1006//
1007//	   return FALSE;
1008//	}
1009//
1010// ...
1011//
1012// GRegex *reg;
1013// GHashTable *h;
1014// gchar *res;
1015//
1016// h = g_hash_table_new (g_str_hash, g_str_equal);
1017//
1018// g_hash_table_insert (h, "1", "ONE");
1019// g_hash_table_insert (h, "2", "TWO");
1020// g_hash_table_insert (h, "3", "THREE");
1021// g_hash_table_insert (h, "4", "FOUR");
1022//
1023// reg = g_regex_new ("1|2|3|4", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL);
1024// res = g_regex_replace_eval (reg, text, -1, 0, 0, eval_cb, h, NULL);
1025// g_hash_table_destroy (h);
1026//
1027// ...
1028// ]|
1029func (x *Regex) ReplaceEval(StringVar []string, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, EvalVar *RegexEvalCallback, UserDataVar uintptr) (string, error) {
1030	var cerr *Error
1031
1032	var EvalVarRef uintptr
1033	if EvalVar != nil {
1034		EvalVarPtr := uintptr(unsafe.Pointer(EvalVar))
1035		if cbRefPtr, ok := GetCallback(EvalVarPtr); ok {
1036			EvalVarRef = cbRefPtr
1037		} else {
1038			fcb := func(arg0 *MatchInfo, arg1 *String, arg2 uintptr) bool {
1039				cbFn := *EvalVar
1040				return cbFn(arg0, arg1, arg2)
1041			}
1042			EvalVarRef = purego.NewCallback(fcb)
1043			SaveCallbackWithClosure(EvalVarPtr, EvalVarRef, EvalVar)
1044		}
1045	}
1046
1047	cret := xRegexReplaceEval(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, EvalVarRef, UserDataVar, &cerr)
1048	if cerr == nil {
1049		return cret, nil
1050	}
1051	return cret, cerr
1052
1053}
1054
1055var xRegexReplaceLiteral func(uintptr, []string, int, int, string, RegexMatchFlags, **Error) string
1056
1057// Replaces all occurrences of the pattern in @regex with the
1058// replacement text. @replacement is replaced literally, to
1059// include backreferences use g_regex_replace().
1060//
1061// Setting @start_position differs from just passing over a
1062// shortened string and setting %G_REGEX_MATCH_NOTBOL in the
1063// case of a pattern that begins with any kind of lookbehind
1064// assertion, such as "\b".
1065func (x *Regex) ReplaceLiteral(StringVar []string, StringLenVar int, StartPositionVar int, ReplacementVar string, MatchOptionsVar RegexMatchFlags) (string, error) {
1066	var cerr *Error
1067
1068	cret := xRegexReplaceLiteral(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, ReplacementVar, MatchOptionsVar, &cerr)
1069	if cerr == nil {
1070		return cret, nil
1071	}
1072	return cret, cerr
1073
1074}
1075
1076var xRegexSplit func(uintptr, string, RegexMatchFlags) []string
1077
1078// Breaks the string on the pattern, and returns an array of the tokens.
1079// If the pattern contains capturing parentheses, then the text for each
1080// of the substrings will also be returned. If the pattern does not match
1081// anywhere in the string, then the whole string is returned as the first
1082// token.
1083//
1084// As a special case, the result of splitting the empty string "" is an
1085// empty vector, not a vector containing a single string. The reason for
1086// this special case is that being able to represent an empty vector is
1087// typically more useful than consistent handling of empty elements. If
1088// you do need to represent empty elements, you'll need to check for the
1089// empty string before calling this function.
1090//
1091// A pattern that can match empty strings splits @string into separate
1092// characters wherever it matches the empty string between characters.
1093// For example splitting "ab c" using as a separator "\s*", you will get
1094// "a", "b" and "c".
1095func (x *Regex) Split(StringVar string, MatchOptionsVar RegexMatchFlags) []string {
1096
1097	cret := xRegexSplit(x.GoPointer(), StringVar, MatchOptionsVar)
1098	return cret
1099}
1100
1101var xRegexSplitFull func(uintptr, []string, int, int, RegexMatchFlags, int, **Error) []string
1102
1103// Breaks the string on the pattern, and returns an array of the tokens.
1104// If the pattern contains capturing parentheses, then the text for each
1105// of the substrings will also be returned. If the pattern does not match
1106// anywhere in the string, then the whole string is returned as the first
1107// token.
1108//
1109// As a special case, the result of splitting the empty string "" is an
1110// empty vector, not a vector containing a single string. The reason for
1111// this special case is that being able to represent an empty vector is
1112// typically more useful than consistent handling of empty elements. If
1113// you do need to represent empty elements, you'll need to check for the
1114// empty string before calling this function.
1115//
1116// A pattern that can match empty strings splits @string into separate
1117// characters wherever it matches the empty string between characters.
1118// For example splitting "ab c" using as a separator "\s*", you will get
1119// "a", "b" and "c".
1120//
1121// Setting @start_position differs from just passing over a shortened
1122// string and setting %G_REGEX_MATCH_NOTBOL in the case of a pattern
1123// that begins with any kind of lookbehind assertion, such as "\b".
1124func (x *Regex) SplitFull(StringVar []string, StringLenVar int, StartPositionVar int, MatchOptionsVar RegexMatchFlags, MaxTokensVar int) ([]string, error) {
1125	var cerr *Error
1126
1127	cret := xRegexSplitFull(x.GoPointer(), StringVar, StringLenVar, StartPositionVar, MatchOptionsVar, MaxTokensVar, &cerr)
1128	if cerr == nil {
1129		return cret, nil
1130	}
1131	return cret, cerr
1132
1133}
1134
1135var xRegexUnref func(uintptr)
1136
1137// Decreases reference count of @regex by 1. When reference count drops
1138// to zero, it frees all the memory associated with the regex structure.
1139func (x *Regex) Unref() {
1140
1141	xRegexUnref(x.GoPointer())
1142
1143}
1144
1145// Flags specifying compile-time options.
1146type RegexCompileFlags int
1147
1148const (
1149
1150	// No special options set. Since: 2.74
1151	GRegexDefaultValue RegexCompileFlags = 0
1152	// Letters in the pattern match both upper- and
1153	//     lowercase letters. This option can be changed within a pattern
1154	//     by a "(?i)" option setting.
1155	GRegexCaselessValue RegexCompileFlags = 1
1156	// By default, GRegex treats the strings as consisting
1157	//     of a single line of characters (even if it actually contains
1158	//     newlines). The "start of line" metacharacter ("^") matches only
1159	//     at the start of the string, while the "end of line" metacharacter
1160	//     ("$") matches only at the end of the string, or before a terminating
1161	//     newline (unless %G_REGEX_DOLLAR_ENDONLY is set). When
1162	//     %G_REGEX_MULTILINE is set, the "start of line" and "end of line"
1163	//     constructs match immediately following or immediately before any
1164	//     newline in the string, respectively, as well as at the very start
1165	//     and end. This can be changed within a pattern by a "(?m)" option
1166	//     setting.
1167	GRegexMultilineValue RegexCompileFlags = 2
1168	// A dot metacharacter (".") in the pattern matches all
1169	//     characters, including newlines. Without it, newlines are excluded.
1170	//     This option can be changed within a pattern by a ("?s") option setting.
1171	GRegexDotallValue RegexCompileFlags = 4
1172	// Whitespace data characters in the pattern are
1173	//     totally ignored except when escaped or inside a character class.
1174	//     Whitespace does not include the VT character (code 11). In addition,
1175	//     characters between an unescaped "#" outside a character class and
1176	//     the next newline character, inclusive, are also ignored. This can
1177	//     be changed within a pattern by a "(?x)" option setting.
1178	GRegexExtendedValue RegexCompileFlags = 8
1179	// The pattern is forced to be "anchored", that is,
1180	//     it is constrained to match only at the first matching point in the
1181	//     string that is being searched. This effect can also be achieved by
1182	//     appropriate constructs in the pattern itself such as the "^"
1183	//     metacharacter.
1184	GRegexAnchoredValue RegexCompileFlags = 16
1185	// A dollar metacharacter ("$") in the pattern
1186	//     matches only at the end of the string. Without this option, a
1187	//     dollar also matches immediately before the final character if
1188	//     it is a newline (but not before any other newlines). This option
1189	//     is ignored if %G_REGEX_MULTILINE is set.
1190	GRegexDollarEndonlyValue RegexCompileFlags = 32
1191	// Inverts the "greediness" of the quantifiers so that
1192	//     they are not greedy by default, but become greedy if followed by "?".
1193	//     It can also be set by a "(?U)" option setting within the pattern.
1194	GRegexUngreedyValue RegexCompileFlags = 512
1195	// Usually strings must be valid UTF-8 strings, using this
1196	//     flag they are considered as a raw sequence of bytes.
1197	GRegexRawValue RegexCompileFlags = 2048
1198	// Disables the use of numbered capturing
1199	//     parentheses in the pattern. Any opening parenthesis that is not
1200	//     followed by "?" behaves as if it were followed by "?:" but named
1201	//     parentheses can still be used for capturing (and they acquire numbers
1202	//     in the usual way).
1203	GRegexNoAutoCaptureValue RegexCompileFlags = 4096
1204	// Since 2.74 and the port to pcre2, requests JIT
1205	//     compilation, which, if the just-in-time compiler is available, further
1206	//     processes a compiled pattern into machine code that executes much
1207	//     faster. However, it comes at the cost of extra processing before the
1208	//     match is performed, so it is most beneficial to use this when the same
1209	//     compiled pattern is used for matching many times. Before 2.74 this
1210	//     option used the built-in non-JIT optimizations in pcre1.
1211	GRegexOptimizeValue RegexCompileFlags = 8192
1212	// Limits an unanchored pattern to match before (or at) the
1213	//     first newline. Since: 2.34
1214	GRegexFirstlineValue RegexCompileFlags = 262144
1215	// Names used to identify capturing subpatterns need not
1216	//     be unique. This can be helpful for certain types of pattern when it
1217	//     is known that only one instance of the named subpattern can ever be
1218	//     matched.
1219	GRegexDupnamesValue RegexCompileFlags = 524288
1220	// Usually any newline character or character sequence is
1221	//     recognized. If this option is set, the only recognized newline character
1222	//     is '\r'.
1223	GRegexNewlineCrValue RegexCompileFlags = 1048576
1224	// Usually any newline character or character sequence is
1225	//     recognized. If this option is set, the only recognized newline character
1226	//     is '\n'.
1227	GRegexNewlineLfValue RegexCompileFlags = 2097152
1228	// Usually any newline character or character sequence is
1229	//     recognized. If this option is set, the only recognized newline character
1230	//     sequence is '\r\n'.
1231	GRegexNewlineCrlfValue RegexCompileFlags = 3145728
1232	// Usually any newline character or character sequence
1233	//     is recognized. If this option is set, the only recognized newline character
1234	//     sequences are '\r', '\n', and '\r\n'. Since: 2.34
1235	GRegexNewlineAnycrlfValue RegexCompileFlags = 5242880
1236	// Usually any newline character or character sequence
1237	//     is recognised. If this option is set, then "\R" only recognizes the newline
1238	//    characters '\r', '\n' and '\r\n'. Since: 2.34
1239	GRegexBsrAnycrlfValue RegexCompileFlags = 8388608
1240	// Changes behaviour so that it is compatible with
1241	//     JavaScript rather than PCRE. Since GLib 2.74 this is no longer supported,
1242	//     as libpcre2 does not support it. Since: 2.34 Deprecated: 2.74
1243	GRegexJavascriptCompatValue RegexCompileFlags = 33554432
1244)
1245
1246// Flags specifying match-time options.
1247type RegexMatchFlags int
1248
1249const (
1250
1251	// No special options set. Since: 2.74
1252	GRegexMatchDefaultValue RegexMatchFlags = 0
1253	// The pattern is forced to be "anchored", that is,
1254	//     it is constrained to match only at the first matching point in the
1255	//     string that is being searched. This effect can also be achieved by
1256	//     appropriate constructs in the pattern itself such as the "^"
1257	//     metacharacter.
1258	GRegexMatchAnchoredValue RegexMatchFlags = 16
1259	// Specifies that first character of the string is
1260	//     not the beginning of a line, so the circumflex metacharacter should
1261	//     not match before it. Setting this without %G_REGEX_MULTILINE (at
1262	//     compile time) causes circumflex never to match. This option affects
1263	//     only the behaviour of the circumflex metacharacter, it does not
1264	//     affect "\A".
1265	GRegexMatchNotbolValue RegexMatchFlags = 128
1266	// Specifies that the end of the subject string is
1267	//     not the end of a line, so the dollar metacharacter should not match
1268	//     it nor (except in multiline mode) a newline immediately before it.
1269	//     Setting this without %G_REGEX_MULTILINE (at compile time) causes
1270	//     dollar never to match. This option affects only the behaviour of
1271	//     the dollar metacharacter, it does not affect "\Z" or "\z".
1272	GRegexMatchNoteolValue RegexMatchFlags = 256
1273	// An empty string is not considered to be a valid
1274	//     match if this option is set. If there are alternatives in the pattern,
1275	//     they are tried. If all the alternatives match the empty string, the
1276	//     entire match fails. For example, if the pattern "a?b?" is applied to
1277	//     a string not beginning with "a" or "b", it matches the empty string
1278	//     at the start of the string. With this flag set, this match is not
1279	//     valid, so GRegex searches further into the string for occurrences
1280	//     of "a" or "b".
1281	GRegexMatchNotemptyValue RegexMatchFlags = 1024
1282	// Turns on the partial matching feature, for more
1283	//     documentation on partial matching see g_match_info_is_partial_match().
1284	GRegexMatchPartialValue RegexMatchFlags = 32768
1285	// Overrides the newline definition set when
1286	//     creating a new #GRegex, setting the '\r' character as line terminator.
1287	GRegexMatchNewlineCrValue RegexMatchFlags = 1048576
1288	// Overrides the newline definition set when
1289	//     creating a new #GRegex, setting the '\n' character as line terminator.
1290	GRegexMatchNewlineLfValue RegexMatchFlags = 2097152
1291	// Overrides the newline definition set when
1292	//     creating a new #GRegex, setting the '\r\n' characters sequence as line terminator.
1293	GRegexMatchNewlineCrlfValue RegexMatchFlags = 3145728
1294	// Overrides the newline definition set when
1295	//     creating a new #GRegex, any Unicode newline sequence
1296	//     is recognised as a newline. These are '\r', '\n' and '\rn', and the
1297	//     single characters U+000B LINE TABULATION, U+000C FORM FEED (FF),
1298	//     U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and
1299	//     U+2029 PARAGRAPH SEPARATOR.
1300	GRegexMatchNewlineAnyValue RegexMatchFlags = 4194304
1301	// Overrides the newline definition set when
1302	//     creating a new #GRegex; any '\r', '\n', or '\r\n' character sequence
1303	//     is recognized as a newline. Since: 2.34
1304	GRegexMatchNewlineAnycrlfValue RegexMatchFlags = 5242880
1305	// Overrides the newline definition for "\R" set when
1306	//     creating a new #GRegex; only '\r', '\n', or '\r\n' character sequences
1307	//     are recognized as a newline by "\R". Since: 2.34
1308	GRegexMatchBsrAnycrlfValue RegexMatchFlags = 8388608
1309	// Overrides the newline definition for "\R" set when
1310	//     creating a new #GRegex; any Unicode newline character or character sequence
1311	//     are recognized as a newline by "\R". These are '\r', '\n' and '\rn', and the
1312	//     single characters U+000B LINE TABULATION, U+000C FORM FEED (FF),
1313	//     U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and
1314	//     U+2029 PARAGRAPH SEPARATOR. Since: 2.34
1315	GRegexMatchBsrAnyValue RegexMatchFlags = 16777216
1316	// An alias for %G_REGEX_MATCH_PARTIAL. Since: 2.34
1317	GRegexMatchPartialSoftValue RegexMatchFlags = 32768
1318	// Turns on the partial matching feature. In contrast to
1319	//     to %G_REGEX_MATCH_PARTIAL_SOFT, this stops matching as soon as a partial match
1320	//     is found, without continuing to search for a possible complete match. See
1321	//     g_match_info_is_partial_match() for more information. Since: 2.34
1322	GRegexMatchPartialHardValue RegexMatchFlags = 134217728
1323	// Like %G_REGEX_MATCH_NOTEMPTY, but only applied to
1324	//     the start of the matched string. For anchored
1325	//     patterns this can only happen for pattern containing "\K". Since: 2.34
1326	GRegexMatchNotemptyAtstartValue RegexMatchFlags = 268435456
1327)
1328
1329// Error codes returned by regular expressions functions.
1330type RegexError int
1331
1332const (
1333
1334	// Compilation of the regular expression failed.
1335	GRegexErrorCompileValue RegexError = 0
1336	// Optimization of the regular expression failed.
1337	GRegexErrorOptimizeValue RegexError = 1
1338	// Replacement failed due to an ill-formed replacement
1339	//     string.
1340	GRegexErrorReplaceValue RegexError = 2
1341	// The match process failed.
1342	GRegexErrorMatchValue RegexError = 3
1343	// Internal error of the regular expression engine.
1344	//     Since 2.16
1345	GRegexErrorInternalValue RegexError = 4
1346	// "\\" at end of pattern. Since 2.16
1347	GRegexErrorStrayBackslashValue RegexError = 101
1348	// "\\c" at end of pattern. Since 2.16
1349	GRegexErrorMissingControlCharValue RegexError = 102
1350	// Unrecognized character follows "\\".
1351	//     Since 2.16
1352	GRegexErrorUnrecognizedEscapeValue RegexError = 103
1353	// Numbers out of order in "{}"
1354	//     quantifier. Since 2.16
1355	GRegexErrorQuantifiersOutOfOrderValue RegexError = 104
1356	// Number too big in "{}" quantifier.
1357	//     Since 2.16
1358	GRegexErrorQuantifierTooBigValue RegexError = 105
1359	// Missing terminating "]" for
1360	//     character class. Since 2.16
1361	GRegexErrorUnterminatedCharacterClassValue RegexError = 106
1362	// Invalid escape sequence
1363	//     in character class. Since 2.16
1364	GRegexErrorInvalidEscapeInCharacterClassValue RegexError = 107
1365	// Range out of order in character class.
1366	//     Since 2.16
1367	GRegexErrorRangeOutOfOrderValue RegexError = 108
1368	// Nothing to repeat. Since 2.16
1369	GRegexErrorNothingToRepeatValue RegexError = 109
1370	// Unrecognized character after "(?",
1371	//     "(?<" or "(?P". Since 2.16
1372	GRegexErrorUnrecognizedCharacterValue RegexError = 112
1373	// POSIX named classes are
1374	//     supported only within a class. Since 2.16
1375	GRegexErrorPosixNamedClassOutsideClassValue RegexError = 113
1376	// Missing terminating ")" or ")"
1377	//     without opening "(". Since 2.16
1378	GRegexErrorUnmatchedParenthesisValue RegexError = 114
1379	// Reference to non-existent
1380	//     subpattern. Since 2.16
1381	GRegexErrorInexistentSubpatternReferenceValue RegexError = 115
1382	// Missing terminating ")" after comment.
1383	//     Since 2.16
1384	GRegexErrorUnterminatedCommentValue RegexError = 118
1385	// Regular expression too large.
1386	//     Since 2.16
1387	GRegexErrorExpressionTooLargeValue RegexError = 120
1388	// Failed to get memory. Since 2.16
1389	GRegexErrorMemoryErrorValue RegexError = 121
1390	// Lookbehind assertion is not
1391	//     fixed length. Since 2.16
1392	GRegexErrorVariableLengthLookbehindValue RegexError = 125
1393	// Malformed number or name after "(?(".
1394	//     Since 2.16
1395	GRegexErrorMalformedConditionValue RegexError = 126
1396	// Conditional group contains
1397	//     more than two branches. Since 2.16
1398	GRegexErrorTooManyConditionalBranchesValue RegexError = 127
1399	// Assertion expected after "(?(".
1400	//     Since 2.16
1401	GRegexErrorAssertionExpectedValue RegexError = 128
1402	// Unknown POSIX class name.
1403	//     Since 2.16
1404	GRegexErrorUnknownPosixClassNameValue RegexError = 130
1405	// POSIX collating
1406	//     elements are not supported. Since 2.16
1407	GRegexErrorPosixCollatingElementsNotSupportedValue RegexError = 131
1408	// Character value in "\\x{...}" sequence
1409	//     is too large. Since 2.16
1410	GRegexErrorHexCodeTooLargeValue RegexError = 134
1411	// Invalid condition "(?(0)". Since 2.16
1412	GRegexErrorInvalidConditionValue RegexError = 135
1413	// \\C not allowed in
1414	//     lookbehind assertion. Since 2.16
1415	GRegexErrorSingleByteMatchInLookbehindValue RegexError = 136
1416	// Recursive call could loop indefinitely.
1417	//     Since 2.16
1418	GRegexErrorInfiniteLoopValue RegexError = 140
1419	// Missing terminator
1420	//     in subpattern name. Since 2.16
1421	GRegexErrorMissingSubpatternNameTerminatorValue RegexError = 142
1422	// Two named subpatterns have
1423	//     the same name. Since 2.16
1424	GRegexErrorDuplicateSubpatternNameValue RegexError = 143
1425	// Malformed "\\P" or "\\p" sequence.
1426	//     Since 2.16
1427	GRegexErrorMalformedPropertyValue RegexError = 146
1428	// Unknown property name after "\\P" or
1429	//     "\\p". Since 2.16
1430	GRegexErrorUnknownPropertyValue RegexError = 147
1431	// Subpattern name is too long
1432	//     (maximum 32 characters). Since 2.16
1433	GRegexErrorSubpatternNameTooLongValue RegexError = 148
1434	// Too many named subpatterns (maximum
1435	//     10,000). Since 2.16
1436	GRegexErrorTooManySubpatternsValue RegexError = 149
1437	// Octal value is greater than "\\377".
1438	//     Since 2.16
1439	GRegexErrorInvalidOctalValueValue RegexError = 151
1440	// "DEFINE" group contains more
1441	//     than one branch. Since 2.16
1442	GRegexErrorTooManyBranchesInDefineValue RegexError = 154
1443	// Repeating a "DEFINE" group is not allowed.
1444	//     This error is never raised. Since: 2.16 Deprecated: 2.34
1445	GRegexErrorDefineRepetionValue RegexError = 155
1446	// Inconsistent newline options.
1447	//     Since 2.16
1448	GRegexErrorInconsistentNewlineOptionsValue RegexError = 156
1449	// "\\g" is not followed by a braced,
1450	//      angle-bracketed, or quoted name or number, or by a plain number. Since: 2.16
1451	GRegexErrorMissingBackReferenceValue RegexError = 157
1452	// relative reference must not be zero. Since: 2.34
1453	GRegexErrorInvalidRelativeReferenceValue RegexError = 158
1454	// the backtracing
1455	//     control verb used does not allow an argument. Since: 2.34
1456	GRegexErrorBacktrackingControlVerbArgumentForbiddenValue RegexError = 159
1457	// unknown backtracing
1458	//     control verb. Since: 2.34
1459	GRegexErrorUnknownBacktrackingControlVerbValue RegexError = 160
1460	// number is too big in escape sequence. Since: 2.34
1461	GRegexErrorNumberTooBigValue RegexError = 161
1462	// Missing subpattern name. Since: 2.34
1463	GRegexErrorMissingSubpatternNameValue RegexError = 162
1464	// Missing digit. Since 2.34
1465	GRegexErrorMissingDigitValue RegexError = 163
1466	// In JavaScript compatibility mode,
1467	//     "[" is an invalid data character. Since: 2.34
1468	GRegexErrorInvalidDataCharacterValue RegexError = 164
1469	// different names for subpatterns of the
1470	//     same number are not allowed. Since: 2.34
1471	GRegexErrorExtraSubpatternNameValue RegexError = 165
1472	// the backtracing control
1473	//     verb requires an argument. Since: 2.34
1474	GRegexErrorBacktrackingControlVerbArgumentRequiredValue RegexError = 166
1475	// "\\c" must be followed by an ASCII
1476	//     character. Since: 2.34
1477	GRegexErrorInvalidControlCharValue RegexError = 168
1478	// "\\k" is not followed by a braced, angle-bracketed, or
1479	//     quoted name. Since: 2.34
1480	GRegexErrorMissingNameValue RegexError = 169
1481	// "\\N" is not supported in a class. Since: 2.34
1482	GRegexErrorNotSupportedInClassValue RegexError = 171
1483	// too many forward references. Since: 2.34
1484	GRegexErrorTooManyForwardReferencesValue RegexError = 172
1485	// the name is too long in "(*MARK)", "(*PRUNE)",
1486	//     "(*SKIP)", or "(*THEN)". Since: 2.34
1487	GRegexErrorNameTooLongValue RegexError = 175
1488	// the character value in the \\u sequence is
1489	//     too large. Since: 2.34
1490	GRegexErrorCharacterValueTooLargeValue RegexError = 176
1491)
1492
1493var xRegexCheckReplacement func(string, *bool, **Error) bool
1494
1495// Checks whether @replacement is a valid replacement string
1496// (see g_regex_replace()), i.e. that all escape sequences in
1497// it are valid.
1498//
1499// If @has_references is not %NULL then @replacement is checked
1500// for pattern references. For instance, replacement text 'foo\n'
1501// does not contain references and may be evaluated without information
1502// about actual match, but '\0\1' (whole match followed by first
1503// subpattern) requires valid #GMatchInfo object.
1504func RegexCheckReplacement(ReplacementVar string, HasReferencesVar *bool) (bool, error) {
1505	var cerr *Error
1506
1507	cret := xRegexCheckReplacement(ReplacementVar, HasReferencesVar, &cerr)
1508
1509	if cerr == nil {
1510		return cret, nil
1511	}
1512	return cret, cerr
1513
1514}
1515
1516var xRegexEscapeNul func(string, int) string
1517
1518// Escapes the nul characters in @string to "\x00".  It can be used
1519// to compile a regex with embedded nul characters.
1520//
1521// For completeness, @length can be -1 for a nul-terminated string.
1522// In this case the output string will be of course equal to @string.
1523func RegexEscapeNul(StringVar string, LengthVar int) string {
1524
1525	cret := xRegexEscapeNul(StringVar, LengthVar)
1526
1527	return cret
1528}
1529
1530var xRegexEscapeString func(string, int) string
1531
1532// Escapes the special characters used for regular expressions
1533// in @string, for instance "a.b*c" becomes "a\.b\*c". This
1534// function is useful to dynamically generate regular expressions.
1535//
1536// @string can contain nul characters that are replaced with "\0",
1537// in this case remember to specify the correct length of @string
1538// in @length.
1539func RegexEscapeString(StringVar string, LengthVar int) string {
1540
1541	cret := xRegexEscapeString(StringVar, LengthVar)
1542
1543	return cret
1544}
1545
1546var xRegexMatchSimple func(string, string, RegexCompileFlags, RegexMatchFlags) bool
1547
1548// Scans for a match in @string for @pattern.
1549//
1550// This function is equivalent to g_regex_match() but it does not
1551// require to compile the pattern with g_regex_new(), avoiding some
1552// lines of code when you need just to do a match without extracting
1553// substrings, capture counts, and so on.
1554//
1555// If this function is to be called on the same @pattern more than
1556// once, it's more efficient to compile the pattern once with
1557// g_regex_new() and then use g_regex_match().
1558func RegexMatchSimple(PatternVar string, StringVar string, CompileOptionsVar RegexCompileFlags, MatchOptionsVar RegexMatchFlags) bool {
1559
1560	cret := xRegexMatchSimple(PatternVar, StringVar, CompileOptionsVar, MatchOptionsVar)
1561
1562	return cret
1563}
1564
1565var xRegexSplitSimple func(string, string, RegexCompileFlags, RegexMatchFlags) []string
1566
1567// Breaks the string on the pattern, and returns an array of
1568// the tokens. If the pattern contains capturing parentheses,
1569// then the text for each of the substrings will also be returned.
1570// If the pattern does not match anywhere in the string, then the
1571// whole string is returned as the first token.
1572//
1573// This function is equivalent to g_regex_split() but it does
1574// not require to compile the pattern with g_regex_new(), avoiding
1575// some lines of code when you need just to do a split without
1576// extracting substrings, capture counts, and so on.
1577//
1578// If this function is to be called on the same @pattern more than
1579// once, it's more efficient to compile the pattern once with
1580// g_regex_new() and then use g_regex_split().
1581//
1582// As a special case, the result of splitting the empty string ""
1583// is an empty vector, not a vector containing a single string.
1584// The reason for this special case is that being able to represent
1585// an empty vector is typically more useful than consistent handling
1586// of empty elements. If you do need to represent empty elements,
1587// you'll need to check for the empty string before calling this
1588// function.
1589//
1590// A pattern that can match empty strings splits @string into
1591// separate characters wherever it matches the empty string between
1592// characters. For example splitting "ab c" using as a separator
1593// "\s*", you will get "a", "b" and "c".
1594func RegexSplitSimple(PatternVar string, StringVar string, CompileOptionsVar RegexCompileFlags, MatchOptionsVar RegexMatchFlags) []string {
1595
1596	cret := xRegexSplitSimple(PatternVar, StringVar, CompileOptionsVar, MatchOptionsVar)
1597
1598	return cret
1599}
1600
1601func init() {
1602	core.SetPackageName("GLIB", "glib-2.0")
1603	core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
1604	var libs []uintptr
1605	for _, libPath := range core.GetPaths("GLIB") {
1606		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
1607		if err != nil {
1608			panic(err)
1609		}
1610		libs = append(libs, lib)
1611	}
1612
1613	core.PuregoSafeRegister(&xRegexCheckReplacement, libs, "g_regex_check_replacement")
1614	core.PuregoSafeRegister(&xRegexEscapeNul, libs, "g_regex_escape_nul")
1615	core.PuregoSafeRegister(&xRegexEscapeString, libs, "g_regex_escape_string")
1616	core.PuregoSafeRegister(&xRegexMatchSimple, libs, "g_regex_match_simple")
1617	core.PuregoSafeRegister(&xRegexSplitSimple, libs, "g_regex_split_simple")
1618
1619	core.PuregoSafeRegister(&xMatchInfoGLibType, libs, "g_match_info_get_type")
1620
1621	core.PuregoSafeRegister(&xMatchInfoExpandReferences, libs, "g_match_info_expand_references")
1622	core.PuregoSafeRegister(&xMatchInfoFetch, libs, "g_match_info_fetch")
1623	core.PuregoSafeRegister(&xMatchInfoFetchAll, libs, "g_match_info_fetch_all")
1624	core.PuregoSafeRegister(&xMatchInfoFetchNamed, libs, "g_match_info_fetch_named")
1625	core.PuregoSafeRegister(&xMatchInfoFetchNamedPos, libs, "g_match_info_fetch_named_pos")
1626	core.PuregoSafeRegister(&xMatchInfoFetchPos, libs, "g_match_info_fetch_pos")
1627	core.PuregoSafeRegister(&xMatchInfoFree, libs, "g_match_info_free")
1628	core.PuregoSafeRegister(&xMatchInfoGetMatchCount, libs, "g_match_info_get_match_count")
1629	core.PuregoSafeRegister(&xMatchInfoGetRegex, libs, "g_match_info_get_regex")
1630	core.PuregoSafeRegister(&xMatchInfoGetString, libs, "g_match_info_get_string")
1631	core.PuregoSafeRegister(&xMatchInfoIsPartialMatch, libs, "g_match_info_is_partial_match")
1632	core.PuregoSafeRegister(&xMatchInfoMatches, libs, "g_match_info_matches")
1633	core.PuregoSafeRegister(&xMatchInfoNext, libs, "g_match_info_next")
1634	core.PuregoSafeRegister(&xMatchInfoRef, libs, "g_match_info_ref")
1635	core.PuregoSafeRegister(&xMatchInfoUnref, libs, "g_match_info_unref")
1636
1637	core.PuregoSafeRegister(&xRegexGLibType, libs, "g_regex_get_type")
1638
1639	core.PuregoSafeRegister(&xNewRegex, libs, "g_regex_new")
1640
1641	core.PuregoSafeRegister(&xRegexGetCaptureCount, libs, "g_regex_get_capture_count")
1642	core.PuregoSafeRegister(&xRegexGetCompileFlags, libs, "g_regex_get_compile_flags")
1643	core.PuregoSafeRegister(&xRegexGetHasCrOrLf, libs, "g_regex_get_has_cr_or_lf")
1644	core.PuregoSafeRegister(&xRegexGetMatchFlags, libs, "g_regex_get_match_flags")
1645	core.PuregoSafeRegister(&xRegexGetMaxBackref, libs, "g_regex_get_max_backref")
1646	core.PuregoSafeRegister(&xRegexGetMaxLookbehind, libs, "g_regex_get_max_lookbehind")
1647	core.PuregoSafeRegister(&xRegexGetPattern, libs, "g_regex_get_pattern")
1648	core.PuregoSafeRegister(&xRegexGetStringNumber, libs, "g_regex_get_string_number")
1649	core.PuregoSafeRegister(&xRegexMatch, libs, "g_regex_match")
1650	core.PuregoSafeRegister(&xRegexMatchAll, libs, "g_regex_match_all")
1651	core.PuregoSafeRegister(&xRegexMatchAllFull, libs, "g_regex_match_all_full")
1652	core.PuregoSafeRegister(&xRegexMatchFull, libs, "g_regex_match_full")
1653	core.PuregoSafeRegister(&xRegexRef, libs, "g_regex_ref")
1654	core.PuregoSafeRegister(&xRegexReplace, libs, "g_regex_replace")
1655	core.PuregoSafeRegister(&xRegexReplaceEval, libs, "g_regex_replace_eval")
1656	core.PuregoSafeRegister(&xRegexReplaceLiteral, libs, "g_regex_replace_literal")
1657	core.PuregoSafeRegister(&xRegexSplit, libs, "g_regex_split")
1658	core.PuregoSafeRegister(&xRegexSplitFull, libs, "g_regex_split_full")
1659	core.PuregoSafeRegister(&xRegexUnref, libs, "g_regex_unref")
1660
1661}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close