c-lang 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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
  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 regex \^#include C
  14. >0 regex \^class[[:space:]]+
  15. >>&0 regex \\{[\.\*]\\}(;)?$ \b++
  16. >&0 clear x source text
  17. !:strength + 13
  18. !:mime text/x-c
  19. 0 regex \^#[[:space:]]*pragma C source text
  20. !:mime text/x-c
  21. 0 regex \^#[[:space:]]*(if\|ifn)def
  22. >&0 regex \^#[[:space:]]*endif$ C source text
  23. !:mime text/x-c
  24. 0 regex \^#[[:space:]]*(if\|ifn)def
  25. >&0 regex \^#[[:space:]]*define C source text
  26. !:mime text/x-c
  27. 0 regex \^[[:space:]]*char(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
  28. !:mime text/x-c
  29. 0 regex \^[[:space:]]*double(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
  30. !:mime text/x-c
  31. 0 regex \^[[:space:]]*extern[[:space:]]+ C source text
  32. !:mime text/x-c
  33. 0 regex \^[[:space:]]*float(\ \\*|\\*)(.+)(=.*)?;[[:space:]]*$ C source text
  34. !:mime text/x-c
  35. 0 regex \^struct[[:space:]]+ C source text
  36. !:mime text/x-c
  37. 0 regex \^union[[:space:]]+ C source text
  38. !:mime text/x-c
  39. 0 search/8192 main(
  40. >&0 regex \\)[[:space:]]*\\{ C source text
  41. !:mime text/x-c
  42. # C++
  43. # The strength of these rules is increased so they beat the C rules above
  44. 0 regex \^namespace[[:space:]]+[_[:alpha:]]{1,30}[[:space:]]*\\{ C++ source text
  45. !:strength + 30
  46. !:mime text/x-c++
  47. # using namespace [namespace] or using std::[lib]
  48. 0 regex \^using[[:space:]]+(namespace\ )?std(::)?[[:alpha:]]*[[:space:]]*; C++ source text
  49. !:strength + 30
  50. !:mime text/x-c++
  51. 0 regex \^[[:space:]]*template[[:space:]]*<.*>[[:space:]]*$ C++ source text
  52. !:strength + 30
  53. !:mime text/x-c++
  54. 0 regex \^[[:space:]]*virtual[[:space:]]+.*[};][[:space:]]*$ C++ source text
  55. !:strength + 30
  56. !:mime text/x-c++
  57. # But class alone is reduced to avoid beating php (Jens Schleusener)
  58. 0 regex \^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]]*\\{(.*[\n]*)*\\}(;)?$ C++ source text
  59. !:strength + 13
  60. !:mime text/x-c++
  61. 0 regex \^[[:space:]]*public: C++ source text
  62. !:strength + 30
  63. !:mime text/x-c++
  64. 0 regex \^[[:space:]]*private: C++ source text
  65. !:strength + 30
  66. !:mime text/x-c++
  67. 0 regex \^[[:space:]]*protected: C++ source text
  68. !:strength + 30
  69. !:mime text/x-c++
  70. # Objective-C
  71. 0 regex \^#import Objective-C source text
  72. !:strength + 25
  73. !:mime text/x-objective-c
  74. # From: Mikhail Teterin <mi@aldan.algebra.com>
  75. 0 string cscope cscope reference data
  76. >7 string x version %.2s
  77. # We skip the path here, because it is often long (so file will
  78. # truncate it) and mostly redundant.
  79. # The inverted index functionality was added some time between
  80. # versions 11 and 15, so look for -q if version is above 14:
  81. >7 string >14
  82. >>10 search/100 \ -q\ with inverted index
  83. >10 search/100 \ -c\ text (non-compressed)