c-lang 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #------------------------------------------------------------------------------
  2. # $File: c-lang,v 1.27 2019/02/27 16:46:23 christos Exp $
  3. # c-lang: file(1) magic for C and related languages programs
  4. #
  5. # The strength is to beat standard HTML
  6. # BCPL
  7. 0 search/8192 "libhdr" BCPL source text
  8. !:mime text/x-bcpl
  9. 0 search/8192 "LIBHDR" BCPL source text
  10. !:mime text/x-bcpl
  11. # C
  12. # Check for class if include is found, otherwise class is beaten by include becouse of lowered strength
  13. 0 search/8192 #include
  14. >0 regex \^#include C
  15. >>0 regex \^class[[:space:]]+
  16. >>>&0 regex \\{[\.\*]\\}(;)?$ \b++
  17. >>&0 clear x source text
  18. !:strength + 13
  19. !:mime text/x-c
  20. 0 search/8192 pragma
  21. >0 regex \^#[[:space:]]*pragma C source text
  22. !:mime text/x-c
  23. 0 search/8192 endif
  24. >0 regex \^#[[:space:]]*(if\|ifn)def
  25. >>&0 regex \^#[[:space:]]*endif$ C source text
  26. !:mime text/x-c
  27. 0 search/8192 define
  28. >0 regex \^#[[:space:]]*(if\|ifn)def
  29. >>&0 regex \^#[[:space:]]*define C source text
  30. !:mime text/x-c
  31. 0 search/8192 char
  32. >0 regex \^[[:space:]]*char(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
  33. !:mime text/x-c
  34. 0 search/8192 double
  35. >0 regex \^[[:space:]]*double(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
  36. !:mime text/x-c
  37. 0 search/8192 extern
  38. >0 regex \^[[:space:]]*extern[[:space:]]+ C source text
  39. !:mime text/x-c
  40. 0 search/8192 float
  41. >0 regex \^[[:space:]]*float(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
  42. !:mime text/x-c
  43. 0 search/8192 struct
  44. >0 regex \^struct[[:space:]]+ C source text
  45. !:mime text/x-c
  46. 0 search/8192 union
  47. >0 regex \^union[[:space:]]+ C source text
  48. !:mime text/x-c
  49. 0 search/8192 main(
  50. >&0 regex \\)[[:space:]]*\\{ C source text
  51. !:mime text/x-c
  52. # C++
  53. # The strength of these rules is increased so they beat the C rules above
  54. 0 search/8192 namespace
  55. >0 regex \^namespace[[:space:]]+[_[:alpha:]]{1,30}[[:space:]]*\\{ C++ source text
  56. !:strength + 30
  57. !:mime text/x-c++
  58. # using namespace [namespace] or using std::[lib]
  59. 0 search/8192 using
  60. >0 regex \^using[[:space:]]+(namespace\ )?std(::)?[[:alpha:]]*[[:space:]]*; C++ source text
  61. !:strength + 30
  62. !:mime text/x-c++
  63. 0 search/8192 template
  64. >0 regex \^[[:space:]]*template[[:space:]]*<.*>[[:space:]]*$ C++ source text
  65. !:strength + 30
  66. !:mime text/x-c++
  67. 0 search/8192 virtual
  68. >0 regex \^[[:space:]]*virtual[[:space:]]+.*[};][[:space:]]*$ C++ source text
  69. !:strength + 30
  70. !:mime text/x-c++
  71. # But class alone is reduced to avoid beating php (Jens Schleusener)
  72. 0 search/8192 class
  73. >0 regex \^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$ C++ source text
  74. !:strength + 13
  75. !:mime text/x-c++
  76. 0 search/8192 public
  77. >0 regex \^[[:space:]]*public: C++ source text
  78. !:strength + 30
  79. !:mime text/x-c++
  80. 0 search/8192 private
  81. >0 regex \^[[:space:]]*private: C++ source text
  82. !:strength + 30
  83. !:mime text/x-c++
  84. 0 search/8192 protected
  85. >0 regex \^[[:space:]]*protected: C++ source text
  86. !:strength + 30
  87. !:mime text/x-c++
  88. # Objective-C
  89. 0 search/8192 #import
  90. >0 regex \^#import Objective-C source text
  91. !:strength + 25
  92. !:mime text/x-objective-c
  93. # From: Mikhail Teterin <mi@aldan.algebra.com>
  94. 0 string cscope cscope reference data
  95. >7 string x version %.2s
  96. # We skip the path here, because it is often long (so file will
  97. # truncate it) and mostly redundant.
  98. # The inverted index functionality was added some time between
  99. # versions 11 and 15, so look for -q if version is above 14:
  100. >7 string >14
  101. >>10 search/100 \ -q\ with inverted index
  102. >10 search/100 \ -c\ text (non-compressed)