diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d0884dab..658931b3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,7 @@ This can usually be solved either by adding a new filename or file name extensio ### Syntax highlighting looks wrong -Assuming your code is being detected as the right language (see above), in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream. +Assuming your code is being detected as the right language (see above), in most cases this is due to a bug in the language grammar rather than a bug in Linguist. [`grammars.yml`][grammars] lists all the grammars we use for syntax highlighting on github.com. Find the one corresponding to your code's programming language and submit a bug report upstream. If you can, try to reproduce the highlighting problem in the text editor that the grammar is designed for (TextMate, Sublime Text, or Atom) and include that information in your bug report. You can also try to fix the bug yourself and submit a Pull Request. [This piece from TextMate's documentation](http://manual.macromates.com/en/language_grammars) offers a good introduction on how to work with TextMate-compatible grammars. You can test grammars using [Lightshow](https://lightshow.githubapp.com). diff --git a/grammars.yml b/grammars.yml index 0c3a0f16..c921d505 100644 --- a/grammars.yml +++ b/grammars.yml @@ -9,8 +9,6 @@ http://svn.textmate.org/trunk/Review/Bundles/Forth.tmbundle: - source.forth http://svn.textmate.org/trunk/Review/Bundles/Parrot.tmbundle: - source.parrot.pir -http://svn.textmate.org/trunk/Review/Bundles/Ruby%20Sass.tmbundle: -- source.sass http://svn.textmate.org/trunk/Review/Bundles/SecondLife%20LSL.tmbundle: - source.lsl http://svn.textmate.org/trunk/Review/Bundles/VHDL.tmbundle: @@ -85,6 +83,8 @@ https://github.com/atom/language-csharp: - source.cs - source.csx - source.nant-build +https://github.com/atom/language-gfm: +- text.html.markdown https://github.com/atom/language-javascript: - source.js - source.js.regexp @@ -92,6 +92,9 @@ https://github.com/atom/language-python: - source.python - source.regexp.python - text.python.traceback +https://github.com/atom/language-sass: +- source.css.scss +- source.sass https://github.com/atom/language-shellscript: - source.shell - text.shell-session @@ -170,6 +173,7 @@ https://github.com/lavrton/sublime-better-typescript: https://github.com/leafo/moonscript-tmbundle: - source.moonscript https://github.com/lsf37/Isabelle.tmbundle: +- source.isabelle.root - source.isabelle.theory https://github.com/lunixbochs/x86-assembly-textmate-bundle: - source.asm.x86 @@ -323,8 +327,6 @@ https://github.com/textmate/lua.tmbundle: - source.lua https://github.com/textmate/make.tmbundle: - source.makefile -https://github.com/textmate/markdown.tmbundle: -- text.html.markdown https://github.com/textmate/matlab.tmbundle: - source.matlab - source.octave diff --git a/lib/linguist/language.rb b/lib/linguist/language.rb index 78aee90b..210b244d 100644 --- a/lib/linguist/language.rb +++ b/lib/linguist/language.rb @@ -269,8 +269,12 @@ module Linguist # Public: A List of languages compatible with Ace. # + # TODO: Remove this method in a 5.x release. Every language now needs an ace_mode + # key, so this function isn't doing anything unique anymore. + # # Returns an Array of Languages. def self.ace_modes + warn "This method will be deprecated in a future 5.x release. Every language now has an `ace_mode` set." @ace_modes ||= all.select(&:ace_mode).sort_by { |lang| lang.name.downcase } end diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index d129fa0a..e1b08727 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -5,7 +5,7 @@ # includes name.downcase) # ace_mode - A String name of the Ace Mode used for highlighting whenever # a file is edited. This must match one of the filenames in http://git.io/3XO_Cg. -# Use "none" if a mode does not exist. +# Use "text" if a mode does not exist. # wrap - Boolean wrap to enable line wrapping (default: false) # extensions - An Array of associated extensions (the first one is # considered the primary extension) @@ -46,7 +46,7 @@ ANTLR: color: "#9DC3FF" extensions: - .g4 - ace_mode: none + ace_mode: text APL: type: programming @@ -55,7 +55,7 @@ APL: - .apl - .dyalog tm_scope: none - ace_mode: none + ace_mode: text ASP: type: programming @@ -72,7 +72,7 @@ ASP: - .asmx - .aspx - .axd - ace_mode: none + ace_mode: text ATS: type: programming @@ -116,14 +116,14 @@ Agda: color: "#467C91" extensions: - .agda - ace_mode: none + ace_mode: text Alloy: type: programming # 'modeling' would be more appropiate color: "#cc5c24" extensions: - .als - ace_mode: none + ace_mode: text Ant Build System: type: data @@ -168,7 +168,7 @@ Arc: extensions: - .arc tm_scope: none - ace_mode: none + ace_mode: text Arduino: type: programming @@ -194,7 +194,7 @@ AspectJ: extensions: - .aj tm_scope: none - ace_mode: none + ace_mode: text Assembly: type: programming @@ -214,7 +214,7 @@ Augeas: extensions: - .aug tm_scope: none - ace_mode: none + ace_mode: text AutoHotkey: type: programming @@ -252,7 +252,7 @@ Awk: - gawk - mawk - nawk - ace_mode: none + ace_mode: text Batchfile: type: programming @@ -272,14 +272,14 @@ Batchfile: Befunge: extensions: - .befunge - ace_mode: none + ace_mode: text Bison: type: programming tm_scope: source.bison extensions: - .y - ace_mode: none + ace_mode: text BlitzBasic: type: programming @@ -292,7 +292,7 @@ BlitzBasic: - .bb - .decls tm_scope: source.blitzmax - ace_mode: none + ace_mode: text BlitzMax: type: programming @@ -301,7 +301,7 @@ BlitzMax: - .bmx aliases: - bmax - ace_mode: none + ace_mode: text Bluespec: type: programming @@ -315,27 +315,27 @@ Boo: color: "#d4bec1" extensions: - .boo - ace_mode: none + ace_mode: text Brainfuck: extensions: - .b - .bf tm_scope: source.bf - ace_mode: none + ace_mode: text Brightscript: type: programming extensions: - .brs tm_scope: none - ace_mode: none + ace_mode: text Bro: type: programming extensions: - .bro - ace_mode: none + ace_mode: text C: type: programming @@ -407,7 +407,7 @@ CLIPS: extensions: - .clp tm_scope: none - ace_mode: none + ace_mode: text CMake: extensions: @@ -415,7 +415,7 @@ CMake: - .in filenames: - CMakeLists.txt - ace_mode: none + ace_mode: text COBOL: type: programming @@ -440,13 +440,13 @@ Cap'n Proto: tm_scope: source.capnp extensions: - .capnp - ace_mode: none + ace_mode: text Ceylon: type: programming extensions: - .ceylon - ace_mode: none + ace_mode: text Chapel: type: programming @@ -455,7 +455,7 @@ Chapel: - chpl extensions: - .chpl - ace_mode: none + ace_mode: text ChucK: extensions: @@ -477,7 +477,7 @@ Clean: - .icl - .dcl tm_scope: none - ace_mode: none + ace_mode: text Clojure: type: programming @@ -579,14 +579,14 @@ Cool: extensions: - .cl tm_scope: source.cool - ace_mode: none + ace_mode: text Coq: type: programming extensions: - .coq - .v - ace_mode: none + ace_mode: text Cpp-ObjDump: type: data @@ -607,7 +607,7 @@ Creole: extensions: - .creole tm_scope: none - ace_mode: none + ace_mode: text Crystal: type: programming @@ -624,7 +624,7 @@ Cucumber: tm_scope: text.gherkin.feature aliases: - gherkin - ace_mode: none + ace_mode: text Cuda: type: programming @@ -650,7 +650,7 @@ Cython: - .pxi aliases: - pyrex - ace_mode: none + ace_mode: text D: type: programming @@ -685,7 +685,7 @@ Darcs Patch: - .darcspatch - .dpatch tm_scope: none - ace_mode: none + ace_mode: text Dart: type: programming @@ -717,7 +717,7 @@ Dogescript: extensions: - .djs tm_scope: none - ace_mode: none + ace_mode: text Dylan: type: programming @@ -727,7 +727,7 @@ Dylan: - .dyl - .intr - .lid - ace_mode: none + ace_mode: text E: type: programming @@ -735,7 +735,7 @@ E: extensions: - .E tm_scope: none - ace_mode: none + ace_mode: text ECL: type: programming @@ -744,7 +744,7 @@ ECL: - .ecl - .eclxml tm_scope: none - ace_mode: none + ace_mode: text Eagle: type: markup @@ -831,7 +831,7 @@ F#: - .fsi - .fsx tm_scope: source.fsharp - ace_mode: none + ace_mode: text FLUX: type: programming @@ -840,7 +840,7 @@ FLUX: - .fx - .flux tm_scope: none - ace_mode: none + ace_mode: text FORTRAN: type: programming @@ -863,7 +863,7 @@ FORTRAN: - .for - .fpp tm_scope: source.fortran.modern - ace_mode: none + ace_mode: text Factor: type: programming @@ -873,7 +873,7 @@ Factor: filenames: - .factor-boot-rc - .factor-rc - ace_mode: none + ace_mode: text Fancy: type: programming @@ -883,7 +883,7 @@ Fancy: - .fancypack filenames: - Fakefile - ace_mode: none + ace_mode: text Fantom: type: programming @@ -891,7 +891,7 @@ Fantom: extensions: - .fan tm_scope: source.fan - ace_mode: none + ace_mode: text Forth: type: programming @@ -930,7 +930,7 @@ GAMS: extensions: - .gms tm_scope: none - ace_mode: none + ace_mode: text GAP: type: programming @@ -940,7 +940,7 @@ GAP: - .gd - .gi tm_scope: none - ace_mode: none + ace_mode: text GAS: type: programming @@ -956,7 +956,7 @@ GDScript: extensions: - .gd tm_scope: none - ace_mode: none + ace_mode: text GLSL: group: C @@ -1018,7 +1018,7 @@ Gettext Catalog: - .po - .pot tm_scope: source.po - ace_mode: none + ace_mode: text Glyph: type: programming @@ -1039,7 +1039,7 @@ Gnuplot: - .plt interpreters: - gnuplot - ace_mode: none + ace_mode: text Go: type: programming @@ -1054,7 +1054,7 @@ Golo: extensions: - .golo tm_scope: none - ace_mode: none + ace_mode: text Gosu: type: programming @@ -1065,21 +1065,21 @@ Gosu: - .gsx - .vark tm_scope: source.gosu.2 - ace_mode: none + ace_mode: text Grace: type: programming extensions: - .grace tm_scope: none - ace_mode: none + ace_mode: text Gradle: type: data extensions: - .gradle tm_scope: source.groovy.gradle - ace_mode: none + ace_mode: text Grammatical Framework: type: programming @@ -1098,7 +1098,7 @@ Graph Modeling Language: extensions: - .gml tm_scope: none - ace_mode: none + ace_mode: text Graphviz (DOT): type: data @@ -1107,7 +1107,7 @@ Graphviz (DOT): - .dot - .DOT - .gv - ace_mode: none + ace_mode: text Groff: extensions: @@ -1122,7 +1122,7 @@ Groff: tm_scope: text.groff aliases: - nroff - ace_mode: none + ace_mode: text Groovy: type: programming @@ -1196,7 +1196,7 @@ HTTP: extensions: - .http tm_scope: none - ace_mode: none + ace_mode: text Hack: type: programming @@ -1230,7 +1230,7 @@ Harbour: extensions: - .hb tm_scope: none - ace_mode: none + ace_mode: text Haskell: type: programming @@ -1265,7 +1265,7 @@ IDL: extensions: - .pro - .dlm - ace_mode: none + ace_mode: text IGOR Pro: type: programming @@ -1275,7 +1275,7 @@ IGOR Pro: - igor - igorpro tm_scope: none - ace_mode: none + ace_mode: text INI: type: data @@ -1298,14 +1298,14 @@ IRC log: - .irclog - .weechatlog tm_scope: none - ace_mode: none + ace_mode: text Idris: type: programming extensions: - .idr - .lidr - ace_mode: none + ace_mode: text Inform 7: type: programming @@ -1317,13 +1317,13 @@ Inform 7: aliases: - i7 - inform7 - ace_mode: none + ace_mode: text Inno Setup: extensions: - .iss tm_scope: none - ace_mode: none + ace_mode: text Io: type: programming @@ -1339,7 +1339,7 @@ Ioke: - .ik interpreters: - ioke - ace_mode: none + ace_mode: text Isabelle: type: programming @@ -1347,14 +1347,14 @@ Isabelle: extensions: - .thy tm_scope: source.isabelle.theory - ace_mode: none + ace_mode: text J: type: programming extensions: - .ijs tm_scope: none - ace_mode: none + ace_mode: text JSON: type: data @@ -1468,7 +1468,7 @@ KRL: extensions: - .krl tm_scope: none - ace_mode: none + ace_mode: text Kit: type: markup @@ -1484,7 +1484,7 @@ Kotlin: - .ktm - .kts tm_scope: source.Kotlin - ace_mode: none + ace_mode: text LFE: type: programming @@ -1498,7 +1498,7 @@ LFE: LLVM: extensions: - .ll - ace_mode: none + ace_mode: text LOLCODE: type: programming @@ -1506,7 +1506,7 @@ LOLCODE: - .lol color: "#cc9900" tm_scope: none - ace_mode: none + ace_mode: text LSL: type: programming @@ -1522,7 +1522,7 @@ LabVIEW: extensions: - .lvproj tm_scope: none - ace_mode: none + ace_mode: text Lasso: type: programming @@ -1536,7 +1536,7 @@ Lasso: tm_scope: file.lasso aliases: - lassoscript - ace_mode: none + ace_mode: text Latte: type: markup @@ -1559,7 +1559,7 @@ LilyPond: extensions: - .ly - .ily - ace_mode: none + ace_mode: text Liquid: type: markup @@ -1574,7 +1574,7 @@ Literate Agda: extensions: - .lagda tm_scope: none - ace_mode: none + ace_mode: text Literate CoffeeScript: type: programming @@ -1587,7 +1587,7 @@ Literate CoffeeScript: - litcoffee extensions: - .litcoffee - ace_mode: none + ace_mode: text Literate Haskell: type: programming @@ -1599,7 +1599,7 @@ Literate Haskell: extensions: - .lhs tm_scope: text.tex.latex.haskell - ace_mode: none + ace_mode: text LiveScript: type: programming @@ -1620,14 +1620,14 @@ Logos: - .xm - .x - .xi - ace_mode: none + ace_mode: text Logtalk: type: programming extensions: - .lgt - .logtalk - ace_mode: none + ace_mode: text LookML: type: programming @@ -1642,7 +1642,7 @@ LoomScript: extensions: - .ls tm_scope: source.loomscript - ace_mode: none + ace_mode: text Lua: type: programming @@ -1698,7 +1698,7 @@ Mako: - .mako - .mao tm_scope: text.html.mako - ace_mode: none + ace_mode: text Markdown: type: prose @@ -1732,7 +1732,7 @@ Mathematica: - .nbp aliases: - mma - ace_mode: none + ace_mode: text Matlab: type: programming @@ -1771,7 +1771,7 @@ MediaWiki: extensions: - .mediawiki tm_scope: none - ace_mode: none + ace_mode: text Mercury: type: programming @@ -1790,7 +1790,7 @@ MiniD: # Legacy extensions: - .minid # Dummy extension tm_scope: none - ace_mode: none + ace_mode: text Mirah: type: programming @@ -1808,14 +1808,14 @@ Monkey: type: programming extensions: - .monkey - ace_mode: none + ace_mode: text Moocode: type: programming extensions: - .moo tm_scope: none - ace_mode: none + ace_mode: text MoonScript: type: programming @@ -1823,26 +1823,26 @@ MoonScript: - .moon interpreters: - moon - ace_mode: none + ace_mode: text Myghty: extensions: - .myt tm_scope: none - ace_mode: none + ace_mode: text NSIS: extensions: - .nsi - .nsh - ace_mode: none + ace_mode: text Nemerle: type: programming color: "#0d3c6e" extensions: - .n - ace_mode: none + ace_mode: text NetLogo: type: programming @@ -1859,7 +1859,7 @@ Nginx: tm_scope: source.nginx aliases: - nginx configuration file - ace_mode: none + ace_mode: text Nimrod: type: programming @@ -1867,14 +1867,14 @@ Nimrod: extensions: - .nim - .nimrod - ace_mode: none + ace_mode: text Ninja: type: data tm_scope: source.ninja extensions: - .ninja - ace_mode: none + ace_mode: text Nit: type: programming @@ -1882,7 +1882,7 @@ Nit: extensions: - .nit tm_scope: none - ace_mode: none + ace_mode: text Nix: type: programming @@ -1915,7 +1915,7 @@ NumPy: - .numpyw - .numsc tm_scope: none - ace_mode: none + ace_mode: text OCaml: type: programming @@ -1973,7 +1973,7 @@ Objective-J: - .j - .sj tm_scope: source.js.objj - ace_mode: none + ace_mode: text Omgrofl: type: programming @@ -1981,13 +1981,13 @@ Omgrofl: - .omgrofl color: "#cabbff" tm_scope: none - ace_mode: none + ace_mode: text Opa: type: programming extensions: - .opa - ace_mode: none + ace_mode: text Opal: type: programming @@ -1995,7 +1995,7 @@ Opal: extensions: - .opal tm_scope: none - ace_mode: none + ace_mode: text OpenCL: type: programming @@ -2016,14 +2016,14 @@ OpenEdge ABL: - .p - .cls tm_scope: source.abl - ace_mode: none + ace_mode: text OpenSCAD: type: programming extensions: - .scad tm_scope: none - ace_mode: none + ace_mode: text Org: type: prose @@ -2031,7 +2031,7 @@ Org: extensions: - .org tm_scope: none - ace_mode: none + ace_mode: text Ox: type: programming @@ -2040,7 +2040,7 @@ Ox: - .oxh - .oxo tm_scope: none - ace_mode: none + ace_mode: text Oxygene: type: programming @@ -2048,7 +2048,7 @@ Oxygene: extensions: - .oxygene tm_scope: none - ace_mode: none + ace_mode: text Oz: type: programming @@ -2056,7 +2056,7 @@ Oz: extensions: - .oz tm_scope: source.oz - ace_mode: none + ace_mode: text PAWN: type: programming @@ -2093,7 +2093,7 @@ Pan: extensions: - .pan tm_scope: none - ace_mode: none + ace_mode: text Papyrus: type: programming @@ -2101,7 +2101,7 @@ Papyrus: extensions: - .psc tm_scope: none - ace_mode: none + ace_mode: text Parrot: type: programming @@ -2109,7 +2109,7 @@ Parrot: extensions: - .parrot # Dummy extension tm_scope: none - ace_mode: none + ace_mode: text Parrot Assembly: group: Parrot @@ -2121,7 +2121,7 @@ Parrot Assembly: interpreters: - parrot tm_scope: none - ace_mode: none + ace_mode: text Parrot Internal Representation: group: Parrot @@ -2133,7 +2133,7 @@ Parrot Internal Representation: - .pir interpreters: - parrot - ace_mode: none + ace_mode: text Pascal: type: programming @@ -2191,7 +2191,7 @@ PigLatin: extensions: - .pig tm_scope: none - ace_mode: none + ace_mode: text Pike: type: programming @@ -2199,7 +2199,7 @@ Pike: extensions: - .pike - .pmod - ace_mode: none + ace_mode: text Pod: type: prose @@ -2215,7 +2215,7 @@ PogoScript: extensions: - .pogo tm_scope: none - ace_mode: none + ace_mode: text PostScript: type: markup @@ -2225,7 +2225,7 @@ PostScript: tm_scope: source.postscript aliases: - postscr - ace_mode: none + ace_mode: text PowerShell: type: programming @@ -2242,7 +2242,7 @@ Processing: color: "#2779ab" extensions: - .pde - ace_mode: none + ace_mode: text Prolog: type: programming @@ -2262,7 +2262,7 @@ Propeller Spin: extensions: - .spin tm_scope: none - ace_mode: none + ace_mode: text Protocol Buffer: type: markup @@ -2280,7 +2280,7 @@ Public Key: - .asc - .pub tm_scope: none - ace_mode: none + ace_mode: text Puppet: type: programming @@ -2289,7 +2289,7 @@ Puppet: - .pp filenames: - Modulefile - ace_mode: none + ace_mode: text Pure Data: type: programming @@ -2297,7 +2297,7 @@ Pure Data: extensions: - .pd tm_scope: none - ace_mode: none + ace_mode: text PureScript: type: programming @@ -2342,7 +2342,7 @@ Python traceback: extensions: - .pytb tm_scope: text.python.traceback - ace_mode: none + ace_mode: text QML: type: markup @@ -2350,7 +2350,7 @@ QML: extensions: - .qml tm_scope: source.qml - ace_mode: none + ace_mode: text QMake: extensions: @@ -2358,7 +2358,7 @@ QMake: - .pri interpreters: - qmake - ace_mode: none + ace_mode: text R: type: programming @@ -2406,7 +2406,7 @@ REALbasic: - .rbtbar - .rbuistate tm_scope: source.vbnet - ace_mode: none + ace_mode: text RHTML: type: markup @@ -2447,7 +2447,7 @@ Ragel in Ruby Host: - ragel-rb - ragel-ruby tm_scope: none - ace_mode: none + ace_mode: text Raw token data: search_term: raw @@ -2456,7 +2456,7 @@ Raw token data: extensions: - .raw tm_scope: none - ace_mode: none + ace_mode: text Rebol: type: programming @@ -2467,7 +2467,7 @@ Rebol: - .r2 - .r3 - .rebol - ace_mode: none + ace_mode: text Red: type: programming @@ -2478,13 +2478,13 @@ Red: aliases: - red/system tm_scope: none - ace_mode: none + ace_mode: text Redcode: extensions: - .cw tm_scope: none - ace_mode: none + ace_mode: text RobotFramework: type: programming @@ -2492,7 +2492,7 @@ RobotFramework: - .robot # - .txt tm_scope: text.robot - ace_mode: none + ace_mode: text Rouge: type: programming @@ -2563,7 +2563,7 @@ SAS: extensions: - .sas tm_scope: none - ace_mode: none + ace_mode: text SCSS: type: markup @@ -2580,7 +2580,7 @@ SQF: - .sqf - .hqf tm_scope: source.sqf - ace_mode: none + ace_mode: text SQL: type: data @@ -2634,7 +2634,7 @@ Scaml: extensions: - .scaml tm_scope: source.scaml - ace_mode: none + ace_mode: text Scheme: type: programming @@ -2658,7 +2658,7 @@ Scilab: - .sci - .sce - .tst - ace_mode: none + ace_mode: text Self: type: programming @@ -2666,7 +2666,7 @@ Self: extensions: - .self tm_scope: none - ace_mode: none + ace_mode: text Shell: type: programming @@ -2708,7 +2708,7 @@ Shen: extensions: - .shen tm_scope: none - ace_mode: none + ace_mode: text Slash: type: programming @@ -2716,7 +2716,7 @@ Slash: extensions: - .sl tm_scope: text.html.slash - ace_mode: none + ace_mode: text Slim: group: HTML @@ -2724,7 +2724,7 @@ Slim: color: "#ff8877" extensions: - .slim - ace_mode: none + ace_mode: text Smalltalk: type: programming @@ -2733,7 +2733,7 @@ Smalltalk: - .st aliases: - squeak - ace_mode: none + ace_mode: text Smarty: extensions: @@ -2748,7 +2748,7 @@ SourcePawn: extensions: - .sp tm_scope: source.sp - ace_mode: none + ace_mode: text Squirrel: type: programming @@ -2768,7 +2768,7 @@ Standard ML: - .sig - .sml tm_scope: source.ml - ace_mode: none + ace_mode: text Stata: type: programming @@ -2780,7 +2780,7 @@ Stata: - .mata - .matah - .sthlp - ace_mode: none + ace_mode: text Stylus: type: markup @@ -2797,14 +2797,14 @@ SuperCollider: - .scd - .sc tm_scope: none - ace_mode: none + ace_mode: text Swift: type: programming color: "#ffac45" extensions: - .swift - ace_mode: none + ace_mode: text SystemVerilog: type: programming @@ -2827,7 +2827,7 @@ TXL: extensions: - .txl tm_scope: none - ace_mode: none + ace_mode: text Tcl: type: programming @@ -2879,7 +2879,7 @@ Tea: extensions: - .tea tm_scope: source.tea - ace_mode: none + ace_mode: text Textile: type: prose @@ -2894,7 +2894,7 @@ Thrift: tm_scope: source.thrift extensions: - .thrift - ace_mode: none + ace_mode: text Turing: type: programming @@ -2903,7 +2903,7 @@ Turing: - .t - .tu tm_scope: none - ace_mode: none + ace_mode: text Twig: type: markup @@ -2991,7 +2991,7 @@ VimL: - _vimrc - gvimrc - vimrc - ace_mode: none + ace_mode: text Visual Basic: type: programming @@ -3009,7 +3009,7 @@ Visual Basic: aliases: - vb.net - vbnet - ace_mode: none + ace_mode: text Volt: type: programming @@ -3158,13 +3158,13 @@ Xojo: - .xojo_toolbar - .xojo_window tm_scope: source.vbnet - ace_mode: none + ace_mode: text Xtend: type: programming extensions: - .xtend - ace_mode: none + ace_mode: text YAML: type: data @@ -3193,7 +3193,7 @@ Zimpl: - .zmpl - .zpl tm_scope: none - ace_mode: none + ace_mode: text eC: type: programming @@ -3202,7 +3202,7 @@ eC: - .ec - .eh tm_scope: none - ace_mode: none + ace_mode: text edn: type: data @@ -3218,26 +3218,26 @@ fish: extensions: - .fish tm_scope: none - ace_mode: none + ace_mode: text mupad: extensions: - .mu - ace_mode: none + ace_mode: text nesC: type: programming color: "#ffce3b" extensions: - .nc - ace_mode: none + ace_mode: text ooc: type: programming color: "#b0b77e" extensions: - .ooc - ace_mode: none + ace_mode: text reStructuredText: type: prose @@ -3248,7 +3248,7 @@ reStructuredText: extensions: - .rst - .rest - ace_mode: none + ace_mode: text text: type: prose @@ -3257,7 +3257,7 @@ text: - .txt - .fr tm_scope: none - ace_mode: none + ace_mode: text wisp: type: programming @@ -3273,4 +3273,4 @@ xBase: extensions: - .prg tm_scope: none - ace_mode: none + ace_mode: text diff --git a/lib/linguist/popular.yml b/lib/linguist/popular.yml index 68d9d0b8..1a5cb750 100644 --- a/lib/linguist/popular.yml +++ b/lib/linguist/popular.yml @@ -3,7 +3,6 @@ # This file should only be edited by GitHub staff - ActionScript -- Bash - C - C# - C++ @@ -27,3 +26,4 @@ - SQL - Scala - Scheme +- Shell diff --git a/lib/linguist/shebang.rb b/lib/linguist/shebang.rb index 3405bb62..6f04e866 100644 --- a/lib/linguist/shebang.rb +++ b/lib/linguist/shebang.rb @@ -18,23 +18,32 @@ module Linguist # # Returns a String or nil def self.interpreter(data) - lines = data.lines - return unless match = /^#! ?(.+)$/.match(lines.first) + shebang = data.lines.first - tokens = match[1].split(' ') - script = tokens.first.split('/').last + # First line must start with #! + return unless shebang && shebang.start_with?("#!") + # Get the parts of the shebang without the #! + tokens = shebang.sub(/^#!\s*/, '').strip.split(' ') + + # There was nothing after the #! + return if tokens.empty? + + # Get the name of the interpreter + script = File.basename(tokens.first) + + # Get next argument if interpreter was /usr/bin/env script = tokens[1] if script == 'env' - # If script has an invalid shebang, we might get here + # Interpreter was /usr/bin/env with no arguments return unless script # "python2.6" -> "python2" - script.sub! $1, '' if script =~ /(\.\d+)$/ + script.sub! /(\.\d+)$/, '' # Check for multiline shebang hacks that call `exec` if script == 'sh' && - lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) } + data.lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) } script = $1 end diff --git a/samples/C/bitmap.h b/samples/C/bitmap.h new file mode 100644 index 00000000..30ab99ea --- /dev/null +++ b/samples/C/bitmap.h @@ -0,0 +1,47 @@ +#pragma once + +/* Copyright © 2010 Christoph Sünderhauf + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include "generic.h" + +typedef struct { + uint32_t numbits; + /* an array large enough for numbits to fit in. Might + * (if numbits%8!=0) have some spare bits at the end + */ + uint32_t* bits; +} bitmap_t; + + +// creates a new bitmap. +// CONTENT IS RANDOM! - use bitmap_clearall() to clear the bitmap. +bitmap_t bitmap_init(uint32_t numbits); + +// returns 1 or 0 +uint8_t bitmap_get(bitmap_t bitmap, uint32_t bitnum); +// sets a bit (to 1) +void bitmap_set(bitmap_t bitmap, uint32_t bitnum); +// clears a bit (to 0) +void bitmap_clear(bitmap_t bitmap, uint32_t bitnum); + +// clears every bit to 0 +void bitmap_clearAll(bitmap_t bitmap); + +// finds the first bit set to 0 returns 0 if no cleared bit found (0 is also returned if the first bit is cleared) +uint32_t bitmap_findFirstClear(bitmap_t bitmap); diff --git a/samples/C/color.h b/samples/C/color.h new file mode 100644 index 00000000..5c60b480 --- /dev/null +++ b/samples/C/color.h @@ -0,0 +1,44 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include + +typedef struct { + uint32_t background; + uint32_t foreground; +} console_color_t; + +#define CONSOLE_COLOR_BLACK 0x0 +#define CONSOLE_COLOR_BLUE 0x1 +#define CONSOLE_COLOR_GREEN 0x2 +#define CONSOLE_COLOR_CYAN 0x3 +#define CONSOLE_COLOR_RED 0x4 +#define CONSOLE_COLOR_MAGENTA 0x5 +#define CONSOLE_COLOR_BROWN 0x6 +#define CONSOLE_COLOR_LGREY 0x7 +#define CONSOLE_COLOR_DGREY 0x8 +#define CONSOLE_COLOR_LBLUE 0x9 +#define CONSOLE_COLOR_LGREEN 0xa +#define CONSOLE_COLOR_LCYAN 0xb +#define CONSOLE_COLOR_LRED 0xc +#define CONSOLE_COLOR_LMAGENTA 0xd +#define CONSOLE_COLOR_YELLOW 0xe +#define CONSOLE_COLOR_WHITE 0xf + diff --git a/samples/C/driver.h b/samples/C/driver.h new file mode 100644 index 00000000..e376c97d --- /dev/null +++ b/samples/C/driver.h @@ -0,0 +1,52 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include +#include + +#define CONSOLE_DRV_CAP_CLEAR 0x01 +#define CONSOLE_DRV_CAP_SCROLL 0x02 +#define CONSOLE_DRV_CAP_SET_CURSOR 0x04 + +// Input modifier keys +typedef struct { + bool shift_left:1; + bool shift_right:1; + bool control_left:1; + bool control_right:1; + bool alt:1; + bool super:1; +} console_modifiers_t; + +typedef struct { + char character; + console_modifiers_t* modifiers; +} console_read_t; + +typedef struct { + int (*write)(console_info_t*, char); + console_read_t* (*read)(console_info_t*); + + int capabilities; + + int (*_clear)(console_info_t*); + int (*scroll)(console_info_t*, int32_t); + void (*setCursor)(console_info_t*, uint32_t, uint32_t); +} console_driver_t; diff --git a/samples/C/elf.h b/samples/C/elf.h new file mode 100644 index 00000000..a270eb14 --- /dev/null +++ b/samples/C/elf.h @@ -0,0 +1,70 @@ +#pragma once + +/* Copyright © 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include +#include + +#define ELF_TYPE_NONE 0 +#define ELF_TYPE_REL 1 +#define ELF_TYPE_EXEC 2 +#define ELF_TYPE_DYN 3 +#define ELF_TYPE_CORE 4 + +#define ELF_ARCH_NONE 0 +#define ELF_ARCH_386 3 + +#define ELF_VERSION_CURRENT 1 + +typedef struct { + unsigned char magic[4]; + /* Note: There _is_ other stuff in here, but we don't need it */ + unsigned char pad[12]; +} __attribute__((packed)) elf_ident_t; + +typedef struct { + uint32_t type; + uint32_t offset; + void* virtaddr; + void* physaddr; + uint32_t filesize; + uint32_t memsize; + uint32_t flags; + uint32_t alignment; +} __attribute__((packed)) elf_program_t; + +typedef struct { + elf_ident_t ident; + uint16_t type; /* Object file type */ + uint16_t machine; /* Architecture */ + uint32_t version; /* Object file version */ + void* entry; /* Entry point virtual address */ + uint32_t phoff; /* Program header table file offset */ + uint32_t shoff; /* Section header table file offset */ + uint32_t flags; /* Processor-specific flags */ + uint16_t ehsize; /* ELF header size in bytes */ + uint16_t phentsize; /* Program header table entry size */ + uint16_t phnum; /* Program header table entry count */ + uint16_t shentsize; /* Section header table entry size */ + uint16_t shnum; /* Section header table entry count */ + uint16_t shstrndx; /* Section header string table index */ +} __attribute__((packed)) elf_t; + +task_t* elf_load(elf_t* bin, char* name, char** environ, char** argv, int argc); +task_t* elf_load_file(char* path, char** environ, char** argv, int argc); diff --git a/samples/C/filter.h b/samples/C/filter.h new file mode 100644 index 00000000..a1a13c9f --- /dev/null +++ b/samples/C/filter.h @@ -0,0 +1,45 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include +#include +#include + +struct console_filter { + // General callback for all actions etc. + // Preferred prototype: + // char (char c, console_info_t *info, console_driver_t *input, console_driver_t *output); + char (*callback)(char, console_info_t*, console_driver_t*, console_driver_t*); + + // Specific callbacks for read and write + // Preferred prototype: + // char (char c, console_info_t *info, console_driver_t *input); + char (*read_callback)(char, console_info_t*, console_driver_t*); + + // Preferred prototype: + // char (char c, console_info_t *info, console_driver_t *output); + char (*write_callback)(char, console_info_t*, console_driver_t*); + + // The next filter in the filter chain + struct console_filter* next; +}; + +typedef struct console_filter console_filter_t; + diff --git a/samples/C/info.h b/samples/C/info.h new file mode 100644 index 00000000..50be7b69 --- /dev/null +++ b/samples/C/info.h @@ -0,0 +1,44 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include +#include + +typedef struct { + uint32_t cursor_x; + uint32_t cursor_y; + + uint32_t rows; + uint32_t columns; + + uint32_t tabstop; + + console_color_t default_color; + console_color_t current_color; + + uint8_t nonblocking; + uint8_t reverse_video; + uint8_t bold; + uint8_t blink; + uint8_t underline; + uint8_t newline_mode; + uint8_t auto_echo; + uint8_t handle_backspace; +} console_info_t; diff --git a/samples/C/interface.h b/samples/C/interface.h new file mode 100644 index 00000000..2c3bfeff --- /dev/null +++ b/samples/C/interface.h @@ -0,0 +1,47 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include +#include +#include +#include + +typedef struct { + console_info_t info; + + console_filter_t* input_filter; + console_filter_t* output_filter; + + console_driver_t* input_driver; + console_driver_t* output_driver; +} console_t; + +console_t* default_console; + +// Generate raw console, connected to the Display, Keyboard and the +// ECMA-48-Filter +void console_init(); + +size_t console_write(console_t* console, const char* buffer, int32_t length); +#define console_write2(console, buffer) console_write(console, buffer, strlen(buffer)) +size_t console_read(console_t* console, char* buffer, size_t length); +size_t console_scroll(console_t* console, int32_t pages); + +void console_clear(console_t* console); diff --git a/samples/C/ip4.h b/samples/C/ip4.h new file mode 100644 index 00000000..b2c8a2a8 --- /dev/null +++ b/samples/C/ip4.h @@ -0,0 +1,50 @@ +#pragma once + +/* Copyright © 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include +#include + +#define IP4_TOS_ICMP 0 + +typedef uint32_t ip4_addr_t; + +typedef struct { + unsigned int hl:4; /* both fields are 4 bits */ + unsigned int version:4; + uint8_t tos; + uint16_t len; + uint16_t id; + uint16_t off; + uint8_t ttl; + uint8_t p; + uint16_t checksum; + ip4_addr_t src; + ip4_addr_t dst; +} ip4_header_t; + +typedef struct { + uint8_t type; + uint8_t code; + uint16_t checksum; + uint16_t id; + uint16_t sequence; +} ip4_icmp_header_t; + +void ip4_receive(net_device_t* origin, net_l2proto_t proto, size_t size, void* raw); diff --git a/samples/C/multiboot.h b/samples/C/multiboot.h new file mode 100644 index 00000000..fcbc13e1 --- /dev/null +++ b/samples/C/multiboot.h @@ -0,0 +1,110 @@ +#pragma once + +/* Copyright © 2010, 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include + +#define MULTIBOOT_KERNELMAGIC 0x2BADB002 + +#define MULTIBOOT_FLAG_MEM 0x001 +#define MULTIBOOT_FLAG_DEVICE 0x002 +#define MULTIBOOT_FLAG_CMDLINE 0x004 +#define MULTIBOOT_FLAG_MODS 0x008 +#define MULTIBOOT_FLAG_AOUT 0x010 +#define MULTIBOOT_FLAG_ELF 0x020 +#define MULTIBOOT_FLAG_MMAP 0x040 +#define MULTIBOOT_FLAG_CONFIG 0x080 +#define MULTIBOOT_FLAG_LOADER 0x100 +#define MULTIBOOT_FLAG_APM 0x200 +#define MULTIBOOT_FLAG_VBE 0x400 + +// The symbol table for a.out. +typedef struct +{ + uint32_t tabSize; + uint32_t strSize; + uint32_t addr; + uint32_t reserved; +} __attribute__((packed)) multiboot_aoutSymbolTable_t; + +// The section header table for ELF. +typedef struct +{ + uint32_t num; + uint32_t size; + uint32_t addr; + uint32_t shndx; +} __attribute__((packed)) multiboot_elfSectionHeaderTable_t; + +typedef struct +{ + uint32_t size; + uint64_t addr; + uint64_t length; + uint32_t type; +} __attribute__((packed)) multiboot_memoryMap_t; + +typedef struct +{ + uint32_t start; + uint32_t end; + char* cmdLine; + uint32_t reserved; +} __attribute__((packed)) multiboot_module_t; + +typedef struct +{ + uint32_t flags; + uint32_t memLower; + uint32_t memUpper; + uint32_t bootDevice; + char* cmdLine; + uint32_t modsCount; + multiboot_module_t* modsAddr; + + union + { + multiboot_aoutSymbolTable_t aoutSym; + multiboot_elfSectionHeaderTable_t elfSec; + } u; + + uint32_t mmapLength; + uint32_t mmapAddr; + + uint32_t drivesLength; + uint32_t drivesAddr; + + // ROM configuration table + uint32_t configTable; + + char* bootLoaderName; + uint32_t apmTable; + + // Video + uint32_t vbeControlInfo; + uint32_t vbeModeInfo; + uint16_t vbeMode; + uint16_t vbeInterfaceSeg; + uint16_t vbeInterfaceOff; + uint16_t vbeInterfaceLen; +} __attribute__((packed)) multiboot_info_t; + +multiboot_info_t* multiboot_info; + +void arch_multiboot_printInfo(); diff --git a/samples/C/portio.h b/samples/C/portio.h new file mode 100644 index 00000000..8a805680 --- /dev/null +++ b/samples/C/portio.h @@ -0,0 +1,43 @@ +#pragma once + +/* Copyright © 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include +#include + +// Legacy +#define outb(args...) portio_out8(args) +#define outw(args...) portio_out16(args) +#define outl(args...) portio_out32(args) +#define outq(args...) portio_out64(args) + +#define inb(args...) portio_in8(args) +#define inw(args...) portio_in16(args) +#define inl(args...) portio_in32(args) +#define inq(args...) portio_in64(args) + +void portio_out8(uint16_t port, uint8_t value); +void portio_out16(uint16_t port, uint16_t value); +void portio_out32(uint16_t port, uint32_t value); +void portio_out64(uint16_t port, uint64_t value); + +uint8_t portio_in8(uint16_t port); +uint16_t portio_in16(uint16_t port); +uint32_t portio_in32(uint16_t port); +uint64_t portio_in64(uint16_t port); diff --git a/samples/C/scheduler.h b/samples/C/scheduler.h new file mode 100644 index 00000000..a886003c --- /dev/null +++ b/samples/C/scheduler.h @@ -0,0 +1,69 @@ +#pragma once + +/* Copyright © 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include +#include +#include + +#define SCHEDULER_MAXNAME 256 +#define SCHEDULER_TASK_PATH_MAX 256 + +// Single linked list +typedef struct task { + uint32_t pid; + char name[SCHEDULER_MAXNAME]; + struct task *parent; + cpu_state_t* state; + struct task* next; + struct task* previous; + + void* stack; + void* entry; + struct vmem_context *memory_context; + + // Current task state + enum { + TASK_STATE_KILLED, + TASK_STATE_TERMINATED, + TASK_STATE_BLOCKING, + TASK_STATE_STOPPED, + TASK_STATE_RUNNING + } task_state; + + char** environ; + char** argv; + int argc; + + // TODO Is this actually the same as PATH_MAX in our toolchain? + char cwd[SCHEDULER_TASK_PATH_MAX + 1]; +} task_t; + +int scheduler_state; + +task_t* scheduler_new(void* entry, task_t* parent, char name[SCHEDULER_MAXNAME], + char** environ, char** argv, int argc, struct vmem_context* memory_context, bool map_structs); +void scheduler_add(task_t *task); +void scheduler_terminate_current(); +task_t* scheduler_get_current(); +task_t* scheduler_select(cpu_state_t* lastRegs); +void scheduler_init(); +void scheduler_yield(); +void scheduler_remove(task_t *t); +task_t* scheduler_fork(task_t* to_fork, cpu_state_t* state); \ No newline at end of file diff --git a/samples/C/syscalls.h b/samples/C/syscalls.h new file mode 100644 index 00000000..dc054e2b --- /dev/null +++ b/samples/C/syscalls.h @@ -0,0 +1,95 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include +#include + +#include "syscalls/write.h" +#include "syscalls/exit.h" +#include "syscalls/getpid.h" +#include "syscalls/getppid.h" +#include "syscalls/read.h" +#include "syscalls/brk.h" +#include "syscalls/mmap.h" +#include "syscalls/munmap.h" +#include "syscalls/test.h" +#include "syscalls/hostname.h" +#include "syscalls/uname.h" +#include "syscalls/open.h" +#include "syscalls/execve.h" +#include "syscalls/seek.h" +#include "syscalls/opendir.h" +#include "syscalls/readdir.h" +#include "syscalls/kill.h" +#include "syscalls/getexecdata.h" +#include "syscalls/cwd.h" +#include "syscalls/fork.h" + +syscall_t syscall_table[] = { + NULL, + sys_exit, // 1 + sys_read, // 2 + sys_write, // 3 + sys_getpid, // 4 + sys_brk, // 5 + sys_getppid, // 6 + sys_mmap, // 7 + sys_munmap, // 8 + sys_test, // 9 + sys_get_hostname, // 10 + sys_set_hostname, // 11 + sys_uname, // 12 + sys_open, // 13 + sys_execve, // 14 + sys_seek, // 15 + sys_opendir, // 16 + sys_readdir, // 17 + sys_kill, // 18 + sys_getexecdata, // 19 + sys_chdir, // 20 + sys_getcwd, // 21 + sys_fork, // 22 +}; + +char* syscall_name_table[] = { + NULL, + "exit", // 1 + "read", // 2 + "write", // 3 + "getpid", // 4 + "brk", // 5 + "getppid", // 6 + "mmap", // 7 + "munmap", // 8 + "test", // 9 + "get_hostname", // 10 + "set_hostname", // 11 + "uname", // 12 + "open", // 13 + "execve", // 14 + "seek", // 15 + "opendir", // 16 + "readdir", // 17 + "kill", // 18 + "getexecdata", // 19 + "chdir", // 20 + "getcwd", // 21 + "fork", // 22 +}; diff --git a/samples/C/vfs.h b/samples/C/vfs.h new file mode 100644 index 00000000..3502460d --- /dev/null +++ b/samples/C/vfs.h @@ -0,0 +1,56 @@ +#pragma once + +/* Copyright © 2010, 2011 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include + +#define VFS_SEEK_SET 0 +#define VFS_SEEK_CUR 1 +#define VFS_SEEK_END 2 + +typedef struct { + uint64_t num; + char path[512]; + char mount_path[512]; + uint32_t offset; + uint32_t mountpoint; +} vfs_file_t; + +typedef struct { + uint64_t num; + char path[512]; + char mount_path[512]; + uint32_t mountpoint; +} vfs_dir_t; + +typedef void* (*vfs_read_callback_t)(char* path, uint32_t offset, uint32_t size); +typedef char* (*vfs_read_dir_callback_t)(char* path, uint32_t offset); + + +// Used to always store the last read/write attempt (used for kernel panic debugging) +char vfs_last_read_attempt[512]; + +vfs_file_t* vfs_get_from_id(uint32_t id); +vfs_dir_t* vfs_get_dir_from_id(uint32_t id); +void* vfs_read(vfs_file_t* fp, uint32_t size); +char* vfs_dir_read(vfs_dir_t* dir, uint32_t offset); +void vfs_seek(vfs_file_t* fp, uint32_t offset, int origin); +vfs_file_t* vfs_open(char* path); +vfs_dir_t* vfs_dir_open(char* path); +int vfs_mount(char* path, vfs_read_callback_t read_callback, vfs_read_dir_callback_t read_dir_callback); diff --git a/samples/C/vmem.h b/samples/C/vmem.h new file mode 100644 index 00000000..82bd29be --- /dev/null +++ b/samples/C/vmem.h @@ -0,0 +1,94 @@ +#pragma once + +/* Copyright © 2011 Fritz Grimpen + * Copyright © 2013 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Xelix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Xelix. If not, see . + */ + +#include + +struct vmem_context; + +struct vmem_page +{ + enum + { + VMEM_SECTION_STACK, /* Initial stack */ + VMEM_SECTION_CODE, /* Contains program code and is read-only */ + VMEM_SECTION_DATA, /* Contains static data */ + VMEM_SECTION_HEAP, /* Allocated by brk(2) at runtime */ + VMEM_SECTION_MMAP, /* Allocated by mmap(2) at runtime */ + VMEM_SECTION_KERNEL, /* Contains kernel-internal data */ + VMEM_SECTION_UNMAPPED /* Unmapped */ + } section; + + bool readonly:1; + bool cow:1; /* Copy-on-Write mechanism */ + bool allocated:1; + + void *cow_src_addr; + void *virt_addr; + void *phys_addr; +}; + +typedef void (*vmem_iterator_t)(struct vmem_context *, struct vmem_page *, uint32_t); + +/* Initialize vmem_kernelContext for paging_init() */ +void vmem_init(); +struct vmem_context *vmem_kernelContext; +struct vmem_context *vmem_currentContext; +struct vmem_context *vmem_processContext; +void *vmem_faultAddress; + +/* Some callbacks for magic functions */ +void (*vmem_applyPage)(struct vmem_context *, struct vmem_page *); + +/* Generate new page context */ +struct vmem_context *vmem_new(); +struct vmem_page *vmem_new_page(); + +int vmem_add_page(struct vmem_context *ctx, struct vmem_page *pg); + +struct vmem_page *vmem_get_page_phys(struct vmem_context *ctx, void *phys_addr); +struct vmem_page *vmem_get_page_virt(struct vmem_context *ctx, void *virt_addr); +struct vmem_page *vmem_get_page(struct vmem_context *ctx, uint32_t offset); + +/* Remove pages in a specific context by physical or virtual address */ +struct vmem_page *vmem_rm_page_phys(struct vmem_context *ctx, void *phys_addr); +struct vmem_page *vmem_rm_page_virt(struct vmem_context *ctx, void *virt_addr); + +/* Iterator */ +int vmem_iterate(struct vmem_context *ctx, vmem_iterator_t callback); + +uint32_t vmem_count_pages(struct vmem_context *ctx); +void vmem_dump_page(struct vmem_page *pg); +void vmem_dump(struct vmem_context *ctx); +void vmem_handle_fault(uint32_t code, void *addr, void *instruction); + +/* Get/Set cached paging context */ +void vmem_set_cache(struct vmem_context *ctx, void *cache); +void *vmem_get_cache(struct vmem_context *ctx); + +#ifdef __i386__ + #define PAGE_SIZE 4096 + #define VMEM_ALIGN(x) (typeof(x))(((intptr_t)(x) & 0xFFFFF000) + 0x1000) + #define VMEM_ALIGN_DOWN(x) (typeof(x))( \ + ((intptr_t)(x) - ((intptr_t)(x) % PAGE_SIZE))) +#else + #define PAGE_SIZE 0 + #define VMEM_ALIGN(x) (x) +#endif diff --git a/test/test_language.rb b/test/test_language.rb index 2bfec9fa..fb6e102b 100644 --- a/test/test_language.rb +++ b/test/test_language.rb @@ -308,11 +308,12 @@ class TestLanguage < Test::Unit::TestCase assert_equal 'css', Language['CSS'].ace_mode assert_equal 'lsl', Language['LSL'].ace_mode assert_equal 'javascript', Language['JavaScript'].ace_mode - assert_equal 'none', Language['FORTRAN'].ace_mode + assert_equal 'text', Language['FORTRAN'].ace_mode end def test_ace_modes assert Language.ace_modes.include?(Language['Ruby']) + assert Language.ace_modes.include?(Language['FORTRAN']) end def test_wrap @@ -366,12 +367,21 @@ class TestLanguage < Test::Unit::TestCase File.basename(ace_github_mode["name"], ".js") if ace_github_mode["name"] !~ /_highlight_rules|_test|_worker/ end.compact.uniq.sort.map(&:downcase) - missing = Language.all.reject { |language| language.ace_mode == "none" || existing_ace_modes.include?(language.ace_mode) } + missing = Language.all.reject { |language| language.ace_mode == "text" || existing_ace_modes.include?(language.ace_mode) } message = "The following languages do not have an Ace mode listed in languages.yml. Please add an Ace mode for all new languages.\n" - message << "If no Ace mode exists for a language, mark the language with `ace_mode: none` in lib/linguist/languages.yml.\n" + message << "If no Ace mode exists for a language, mark the language with `ace_mode: text` in lib/linguist/languages.yml.\n" width = missing.map { |language| language.name.length }.max message << missing.map { |language| sprintf("%-#{width}s %s", language.name, language.ace_mode) }.sort.join("\n") assert missing.empty?, message end + + def test_all_popular_languages_exist + popular = YAML.load(File.read(File.expand_path("../../lib/linguist/popular.yml", __FILE__))) + + missing = popular - Language.all.map(&:name) + message = "The following languages are listed in lib/linguist/popular.yml but not in lib/linguist/languages.yml.\n" + message << missing.sort.join("\n") + assert missing.empty?, message + end end diff --git a/test/test_shebang.rb b/test/test_shebang.rb index 4b6b39a6..5ead299d 100644 --- a/test/test_shebang.rb +++ b/test/test_shebang.rb @@ -17,6 +17,8 @@ class TestShebang < Test::Unit::TestCase assert_interpreter nil, " #!/usr/sbin/ruby" assert_interpreter nil, "\n#!/usr/sbin/ruby" assert_interpreter nil, "#!" + assert_interpreter nil, "#! " + assert_interpreter nil, "#!/usr/bin/env" assert_interpreter "ruby", "#!/usr/sbin/ruby\n# bar" assert_interpreter "ruby", "#!/usr/bin/ruby\n# foo" @@ -34,6 +36,8 @@ class TestShebang < Test::Unit::TestCase assert_interpreter "python3", "#!/usr/bin/python3\n\n\n\n" assert_interpreter "sbcl", "#!/usr/bin/sbcl --script\n\n" assert_interpreter "perl", "#! perl" + + assert_interpreter "ruby", "#!/bin/sh\n\n\nexec ruby $0 $@" end end