1 #------------------------------------------------------------------------------
2 # $File: c-lang,v 1.26 2017/08/14 07:40:38 christos Exp $
3 # c-lang: file(1) magic for C and related languages programs
5 # The strength is to beat standard HTML
8 0 search/8192 "libhdr" BCPL source text
10 0 search/8192 "LIBHDR" BCPL source text
14 # Check for class if include is found, otherwise class is beaten by include becouse of lowered strength
16 >0 regex \^class[[:space:]]+
17 >>&0 regex \\{[\.\*]\\}(;)?$ \b++
18 >&0 clear x source text
21 0 regex \^#[[:space:]]*pragma C source text
23 0 regex \^#[[:space:]]*(if\|ifn)def
24 >&0 regex \^#[[:space:]]*endif$ C source text
26 0 regex \^#[[:space:]]*(if\|ifn)def
27 >&0 regex \^#[[:space:]]*define C source text
29 0 regex \^[[:space:]]*char(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
31 0 regex \^[[:space:]]*double(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
33 0 regex \^[[:space:]]*extern[[:space:]]+ C source text
35 0 regex \^[[:space:]]*float(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
37 0 regex \^struct[[:space:]]+ C source text
39 0 regex \^union[[:space:]]+ C source text
42 >&0 regex \\)[[:space:]]*\\{ C source text
46 # The strength of these rules is increased so they beat the C rules above
47 0 regex \^namespace[[:space:]]+[_[:alpha:]]{1,30}[[:space:]]*\\{ C++ source text
50 # using namespace [namespace] or using std::[lib]
51 0 regex \^using[[:space:]]+(namespace\ )?std(::)?[[:alpha:]]*[[:space:]]*; C++ source text
54 0 regex \^[[:space:]]*template[[:space:]]*<.*>[[:space:]]*$ C++ source text
57 0 regex \^[[:space:]]*virtual[[:space:]]+.*[};][[:space:]]*$ C++ source text
60 # But class alone is reduced to avoid beating php (Jens Schleusener)
61 0 regex \^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$ C++ source text
64 0 regex \^[[:space:]]*public: C++ source text
67 0 regex \^[[:space:]]*private: C++ source text
70 0 regex \^[[:space:]]*protected: C++ source text
75 0 regex \^#import Objective-C source text
77 !:mime text/x-objective-c
79 # From: Mikhail Teterin <mi@aldan.algebra.com>
80 0 string cscope cscope reference data
81 >7 string x version %.2s
82 # We skip the path here, because it is often long (so file will
83 # truncate it) and mostly redundant.
84 # The inverted index functionality was added some time between
85 # versions 11 and 15, so look for -q if version is above 14:
87 >>10 search/100 \ -q\ with inverted index
88 >10 search/100 \ -c\ text (non-compressed)