/usr/share/gnudatalanguage/lib/strmatch.pro is in libgnudatalanguage0 0.9.6v2-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | ; part of GDL - GNU Data Language (GPL)
; by Sylwester Arabas <slayoo@igf.fuw.edu.pl>
;
; search & replace helper for strmatch()
;
; 14-Aug-2012 : Now GDL enforces scalar type in FOR loop ... take care
; of STRLEN ! We ensure to work on pure STRING = '' , not STRING = Array[1]
;
function STRMATCH_STRREPLACE, str, a, b
pos = STRPOS(str, a)
if (pos eq -1) then return, str
ret = STRMID(str,0,pos)
la = STRLEN(a[0])
last = pos
for i = pos, STRLEN(str[0]) - 1 do begin
if STRMID(str,i,la) eq a && (i eq 0 || STRMID(str,i-1,1) ne '\') then begin
ret += STRMID(str,last,i-last) + b
last = i + la
endif
endfor
ret += STRMID(str,last)
return, ret
end
; quick & dirty STRMATCH() implementation using STREGEX()
;
function STRMATCH, mstr, sstr, fold_case=fold_case
;
on_error, 2
if (SIZE(sstr))[0] ne 0 then MESSAGE, 'second argument must be a scalar string'
;
tmp = sstr
;; . -> \. (but not \.)
tmp = STRMATCH_STRREPLACE(tmp, '.', '\.')
;; ( -> \( (but not \()
tmp = STRMATCH_STRREPLACE(tmp, '(', '\(')
; ) -> \) (but not \))
tmp = STRMATCH_STRREPLACE(tmp, ')', '\)')
; + -> \+ (but not \+)
tmp = STRMATCH_STRREPLACE(tmp, '+', '\+')
; { -> \{ (but not \{)
tmp = STRMATCH_STRREPLACE(tmp, '{', '\{')
; } -> \} (but not \})
tmp = STRMATCH_STRREPLACE(tmp, '}', '\}')
; | -> \| (but not \|)
tmp = STRMATCH_STRREPLACE(tmp, '|', '\|')
; ^ -> \^ (but not \^)
tmp = STRMATCH_STRREPLACE(tmp, '^', '\^')
; $ -> \$ (but not \$)
tmp = STRMATCH_STRREPLACE(tmp, '$', '\$')
; * -> .* (but not \*)
tmp = STRMATCH_STRREPLACE(tmp, '*', '.*')
; ? -> . (but not \?)
tmp = STRMATCH_STRREPLACE(tmp, '?', '.')
; [!...] -> [^...] (but not \[!...)
tmp = STRMATCH_STRREPLACE(tmp, '[!', '[^')
; the leading a trailing markers
tmp = '^' + tmp + '$'
return, STREGEX(mstr, tmp, /boolean, fold_case=fold_case)
end
|