daemon: Restore PCRE regular expressions in OCaml code.

When parts of the daemon were previously converted to OCaml, the
previous PCRE regexps were converted to Str regexps.  Restore the
original PCRE regexps.

There was also one case where an original call to glob(3) was replaced
by a Str regexp, and this is replaced by a PCRE regexp (although it is
in fact identical in this instance).

This updates commit b48da89dd6
and commit eeda6edca1
and commit 2ca0fa778d.
This commit is contained in:
Richard W.M. Jones
2017-08-01 15:40:56 +01:00
parent e5182b87cf
commit 38359eaf3e
6 changed files with 33 additions and 21 deletions

View File

@@ -25,9 +25,9 @@ open Unix_utils
open Utils
let re_file_elf =
Str.regexp ".*ELF \\([0-9]+\\)-bit \\(MSB\\|LSB\\).*\\(executable\\|shared object\\|relocatable\\), \\([^,]+\\),"
PCRE.compile "ELF (\\d+)-bit (MSB|LSB).*(?:executable|shared object|relocatable), (.+?),"
let re_file_elf_ppc64 = Str.regexp ".*64.*PowerPC"
let re_file_elf_ppc64 = PCRE.compile ".*64.*PowerPC"
let initrd_binaries = [
"bin/ls";
@@ -48,10 +48,10 @@ let rec file_architecture orig_path =
file_architecture_of_magic magic orig_path orig_path
and file_architecture_of_magic magic orig_path path =
if Str.string_match re_file_elf magic 0 then (
let bits = Str.matched_group 1 magic in
let endianness = Str.matched_group 2 magic in
let elf_arch = Str.matched_group 4 magic in
if PCRE.matches re_file_elf magic then (
let bits = PCRE.sub 1 in
let endianness = PCRE.sub 2 in
let elf_arch = PCRE.sub 3 in
canonical_elf_arch bits endianness elf_arch
)
else if String.find magic "PE32 executable" >= 0 then
@@ -78,7 +78,7 @@ and canonical_elf_arch bits endianness elf_arch =
"sparc64"
else if substr "IA-64" then
"ia64"
else if Str.string_match re_file_elf_ppc64 elf_arch 0 then (
else if PCRE.matches re_file_elf_ppc64 elf_arch then (
match endianness with
| "MSB" -> "ppc64"
| "LSB" -> "ppc64le"