1 #------------------------------------------------------------------------------
2 # $File: c-lang,v 1.28 2019/11/15 21:03:14 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 because of lowered strength
15 0 search/8192 #include
17 >>0 regex \^class[[:space:]]+
18 >>>&0 regex \\{[\.\*]\\}(;)?$ \b++
19 >>&0 clear x source text
23 >0 regex \^#[[:space:]]*pragma C source text
26 >0 regex \^#[[:space:]]*(if\|ifn)def
27 >>&0 regex \^#[[:space:]]*endif$ C source text
30 >0 regex \^#[[:space:]]*(if\|ifn)def
31 >>&0 regex \^#[[:space:]]*define C source text
34 >0 regex \^[[:space:]]*char(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
37 >0 regex \^[[:space:]]*double(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
40 >0 regex \^[[:space:]]*extern[[:space:]]+ C source text
43 >0 regex \^[[:space:]]*float(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
46 >0 regex \^struct[[:space:]]+ C source text
49 >0 regex \^union[[:space:]]+ C source text
52 >&0 regex \\)[[:space:]]*\\{ C source text
56 # The strength of these rules is increased so they beat the C rules above
57 0 search/8192 namespace
58 >0 regex \^namespace[[:space:]]+[_[:alpha:]]{1,30}[[:space:]]*\\{ C++ source text
61 # using namespace [namespace] or using std::[lib]
63 >0 regex \^using[[:space:]]+(namespace\ )?std(::)?[[:alpha:]]*[[:space:]]*; C++ source text
66 0 search/8192 template
67 >0 regex \^[[:space:]]*template[[:space:]]*<.*>[[:space:]]*$ C++ source text
71 >0 regex \^[[:space:]]*virtual[[:space:]]+.*[};][[:space:]]*$ C++ source text
74 # But class alone is reduced to avoid beating php (Jens Schleusener)
76 >0 regex \^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$ C++ source text
80 >0 regex \^[[:space:]]*public: C++ source text
84 >0 regex \^[[:space:]]*private: C++ source text
87 0 search/8192 protected
88 >0 regex \^[[:space:]]*protected: C++ source text
94 >0 regex \^#import Objective-C source text
96 !:mime text/x-objective-c
98 # From: Mikhail Teterin <mi@aldan.algebra.com>
99 0 string cscope cscope reference data
100 >7 string x version %.2s
101 # We skip the path here, because it is often long (so file will
102 # truncate it) and mostly redundant.
103 # The inverted index functionality was added some time between
104 # versions 11 and 15, so look for -q if version is above 14:
106 >>10 search/100 \ -q\ with inverted index
107 >10 search/100 \ -c\ text (non-compressed)