mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge branch 'master' into revert-2014-revert-1976-path-for-fileblob
This commit is contained in:
18
.gitmodules
vendored
18
.gitmodules
vendored
@@ -615,6 +615,9 @@
|
||||
[submodule "vendor/grammars/mediawiki.tmbundle"]
|
||||
path = vendor/grammars/mediawiki.tmbundle
|
||||
url = https://github.com/textmate/mediawiki.tmbundle
|
||||
[submodule "vendor/grammars/oracle.tmbundle"]
|
||||
path = vendor/grammars/oracle.tmbundle
|
||||
url = https://github.com/mulander/oracle.tmbundle.git
|
||||
[submodule "vendor/grammars/BrightScript.tmbundle"]
|
||||
path = vendor/grammars/BrightScript.tmbundle
|
||||
url = https://github.com/cmink/BrightScript.tmbundle
|
||||
@@ -627,3 +630,18 @@
|
||||
[submodule "vendor/grammars/sublime-text-pig-latin"]
|
||||
path = vendor/grammars/sublime-text-pig-latin
|
||||
url = https://github.com/goblindegook/sublime-text-pig-latin
|
||||
[submodule "vendor/grammars/Lean.tmbundle"]
|
||||
path = vendor/grammars/Lean.tmbundle
|
||||
url = https://github.com/leanprover/Lean.tmbundle
|
||||
[submodule "vendor/grammars/ampl"]
|
||||
path = vendor/grammars/ampl
|
||||
url = https://github.com/ampl/sublime-ampl
|
||||
[submodule "vendor/grammars/openscad.tmbundle"]
|
||||
path = vendor/grammars/openscad.tmbundle
|
||||
url = https://github.com/tbuser/openscad.tmbundle
|
||||
[submodule "vendor/grammars/sublime-varnish"]
|
||||
path = vendor/grammars/sublime-varnish
|
||||
url = https://github.com/brandonwamboldt/sublime-varnish
|
||||
[submodule "vendor/grammars/xc.tmbundle"]
|
||||
path = vendor/grammars/xc.tmbundle
|
||||
url = https://github.com/graymalkin/xc.tmbundle
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
sudo: false
|
||||
before_install: script/travis/before_install
|
||||
rvm:
|
||||
- 1.9.3
|
||||
|
||||
@@ -26,7 +26,7 @@ Linguist supports a number of different custom overrides strategies for language
|
||||
|
||||
### Using gitattributes
|
||||
|
||||
Add a `.gitattributes` file to your project and use standard git-style path matchers for the files you want to override to set `linguist-documentation`, `linguist-language`, and `linguist-vendored`.
|
||||
Add a `.gitattributes` file to your project and use standard git-style path matchers for the files you want to override to set `linguist-documentation`, `linguist-language`, and `linguist-vendored`. `.gitattributes` will be used to determine language statistics, but will not be used to syntax highlight files. To manually set syntax highlighting, use [Vim or Emacs modelines](#using-emacs-and-vim-modelines).
|
||||
|
||||
```
|
||||
$ cat .gitattributes
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
|
||||
# linguist — detect language type for a file, or, given a directory, determine language breakdown
|
||||
# usage: linguist <path> [<--breakdown>]
|
||||
|
||||
require 'linguist/file_blob'
|
||||
require 'linguist/language'
|
||||
require 'linguist/repository'
|
||||
#
|
||||
require 'linguist'
|
||||
require 'rugged'
|
||||
|
||||
path = ARGV[0] || Dir.pwd
|
||||
|
||||
12
grammars.yml
12
grammars.yml
@@ -63,6 +63,8 @@ vendor/grammars/JSyntax/:
|
||||
- source.j
|
||||
vendor/grammars/Julia.tmbundle:
|
||||
- source.julia
|
||||
vendor/grammars/Lean.tmbundle:
|
||||
- source.lean
|
||||
vendor/grammars/LiveScript.tmbundle:
|
||||
- source.livescript
|
||||
vendor/grammars/Modelica/:
|
||||
@@ -141,6 +143,8 @@ vendor/grammars/actionscript3-tmbundle:
|
||||
- text.xml.flex-config
|
||||
vendor/grammars/ada.tmbundle:
|
||||
- source.ada
|
||||
vendor/grammars/ampl:
|
||||
- source.ampl
|
||||
vendor/grammars/ant.tmbundle:
|
||||
- text.xml.ant
|
||||
vendor/grammars/antlr.tmbundle:
|
||||
@@ -381,6 +385,10 @@ vendor/grammars/ooc.tmbundle:
|
||||
- source.ooc
|
||||
vendor/grammars/opa.tmbundle:
|
||||
- source.opa
|
||||
vendor/grammars/openscad.tmbundle/:
|
||||
- source.scad
|
||||
vendor/grammars/oracle.tmbundle:
|
||||
- source.plsql.oracle
|
||||
vendor/grammars/oz-tmbundle/Syntaxes/Oz.tmLanguage:
|
||||
- source.oz
|
||||
vendor/grammars/pascal.tmbundle:
|
||||
@@ -488,6 +496,8 @@ vendor/grammars/sublime-text-ox/:
|
||||
- source.ox
|
||||
vendor/grammars/sublime-text-pig-latin/:
|
||||
- source.pig_latin
|
||||
vendor/grammars/sublime-varnish:
|
||||
- source.varnish.vcl
|
||||
vendor/grammars/sublime_cobol:
|
||||
- source.acucobol
|
||||
- source.cobol
|
||||
@@ -520,6 +530,8 @@ vendor/grammars/verilog.tmbundle:
|
||||
- source.verilog
|
||||
vendor/grammars/x86-assembly-textmate-bundle:
|
||||
- source.asm.x86
|
||||
vendor/grammars/xc.tmbundle/:
|
||||
- source.xc
|
||||
vendor/grammars/xml.tmbundle:
|
||||
- text.xml
|
||||
- text.xml.xsl
|
||||
|
||||
@@ -6,3 +6,15 @@ require 'linguist/repository'
|
||||
require 'linguist/samples'
|
||||
require 'linguist/shebang'
|
||||
require 'linguist/version'
|
||||
|
||||
class << Linguist
|
||||
attr_accessor :instrumenter
|
||||
|
||||
def instrument(*args, &bk)
|
||||
if instrumenter
|
||||
instrumenter.instrument(*args, &bk)
|
||||
else
|
||||
yield if block_given?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,7 +74,7 @@ module Linguist
|
||||
#
|
||||
# Returns an Array
|
||||
def extensions
|
||||
basename, *segments = name.split(".")
|
||||
basename, *segments = name.downcase.split(".")
|
||||
|
||||
segments.map.with_index do |segment, index|
|
||||
"." + segments[index..-1].join(".")
|
||||
|
||||
@@ -33,7 +33,7 @@ module Linguist
|
||||
# disambiguate "Perl", "Prolog" do |data|
|
||||
# if data.include?("use strict")
|
||||
# Language["Perl"]
|
||||
# elsif data.include?(":-")
|
||||
# elsif /^[^#]+:-/.match(data)
|
||||
# Language["Prolog"]
|
||||
# end
|
||||
# end
|
||||
@@ -94,23 +94,27 @@ module Linguist
|
||||
Language["Perl6"]
|
||||
elsif data.match(/use strict|use\s+v?5\./)
|
||||
Language["Perl"]
|
||||
elsif data.include?(":-")
|
||||
elsif /^[^#]+:-/.match(data)
|
||||
Language["Prolog"]
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate "ECL", "Prolog" do |data|
|
||||
if data.include?(":-")
|
||||
if /^[^#]+:-/.match(data)
|
||||
Language["Prolog"]
|
||||
elsif data.include?(":=")
|
||||
Language["ECL"]
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate "IDL", "Prolog" do |data|
|
||||
if data.include?(":-")
|
||||
disambiguate "IDL", "Prolog", "INI", "QMake" do |data|
|
||||
if /^[^#]+:-/.match(data)
|
||||
Language["Prolog"]
|
||||
else
|
||||
elsif data.include?("last_client=")
|
||||
Language["INI"]
|
||||
elsif data.include?("HEADERS") && data.include?("SOURCES")
|
||||
Language["QMake"]
|
||||
elsif /^\s*function[ \w,]+$/.match(data)
|
||||
Language["IDL"]
|
||||
end
|
||||
end
|
||||
@@ -178,11 +182,13 @@ module Linguist
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate "M", "Mathematica", "Matlab", "Mercury", "Objective-C" do |data|
|
||||
disambiguate "M", "MUF", "Mathematica", "Matlab", "Mercury", "Objective-C" do |data|
|
||||
if ObjectiveCRegex.match(data)
|
||||
Language["Objective-C"]
|
||||
elsif data.include?(":- module")
|
||||
Language["Mercury"]
|
||||
elsif /^: /.match(data)
|
||||
Language["MUF"]
|
||||
elsif /^\s*;/.match(data)
|
||||
Language["M"]
|
||||
elsif /^\s*\(\*/.match(data)
|
||||
@@ -229,5 +235,31 @@ module Linguist
|
||||
Language["Text"]
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate "PLSQL", "SQLPL", "PLpgSQL", "SQL" do |data|
|
||||
if /^\\i\b|AS \$\$|LANGUAGE '+plpgsql'+/i.match(data) || /SECURITY (DEFINER|INVOKER)/i.match(data) || /BEGIN( WORK| TRANSACTION)?;/i.match(data)
|
||||
#Postgres
|
||||
Language["PLpgSQL"]
|
||||
elsif /(alter module)|(language sql)|(begin( NOT)+ atomic)/i.match(data) || /signal SQLSTATE '[0-9]+'/i.match(data)
|
||||
#IBM db2
|
||||
Language["SQLPL"]
|
||||
elsif /pragma|\$\$PLSQL_|XMLTYPE|sysdate|systimestamp|\.nextval|connect by|AUTHID (DEFINER|CURRENT_USER)/i.match(data) || /constructor\W+function/i.match(data)
|
||||
#Oracle
|
||||
Language["PLSQL"]
|
||||
elsif ! /begin|boolean|package|exception/i.match(data)
|
||||
#Generic SQL
|
||||
Language["SQL"]
|
||||
end
|
||||
end
|
||||
|
||||
disambiguate "D", "DTrace", "Makefile" do |data|
|
||||
if /^module /.match(data)
|
||||
Language["D"]
|
||||
elsif /^((dtrace:::)?BEGIN|provider |#pragma (D (option|attributes)|ident)\s)/.match(data)
|
||||
Language["DTrace"]
|
||||
elsif /(\/.*:( .* \\)$| : \\$|^ : |: \\$)/.match(data)
|
||||
Language["Makefile"]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -73,7 +73,7 @@ module Linguist
|
||||
raise ArgumentError, "Extension is missing a '.': #{extension.inspect}"
|
||||
end
|
||||
|
||||
@extension_index[extension] << language
|
||||
@extension_index[extension.downcase] << language
|
||||
end
|
||||
|
||||
language.interpreters.each do |interpreter|
|
||||
@@ -105,19 +105,31 @@ module Linguist
|
||||
# Bail early if the blob is binary or empty.
|
||||
return nil if blob.likely_binary? || blob.binary? || blob.empty?
|
||||
|
||||
# Call each strategy until one candidate is returned.
|
||||
STRATEGIES.reduce([]) do |languages, strategy|
|
||||
candidates = strategy.call(blob, languages)
|
||||
if candidates.size == 1
|
||||
return candidates.first
|
||||
elsif candidates.size > 1
|
||||
# More than one candidate was found, pass them to the next strategy.
|
||||
candidates
|
||||
else
|
||||
# No candiates were found, pass on languages from the previous strategy.
|
||||
languages
|
||||
Linguist.instrument("linguist.detection", :blob => blob) do
|
||||
# Call each strategy until one candidate is returned.
|
||||
languages = []
|
||||
returning_strategy = nil
|
||||
|
||||
STRATEGIES.each do |strategy|
|
||||
returning_strategy = strategy
|
||||
candidates = Linguist.instrument("linguist.strategy", :blob => blob, :strategy => strategy, :candidates => languages) do
|
||||
strategy.call(blob, languages)
|
||||
end
|
||||
if candidates.size == 1
|
||||
languages = candidates
|
||||
break
|
||||
elsif candidates.size > 1
|
||||
# More than one candidate was found, pass them to the next strategy.
|
||||
languages = candidates
|
||||
else
|
||||
# No candidates, try the next strategy
|
||||
end
|
||||
end
|
||||
end.first
|
||||
|
||||
Linguist.instrument("linguist.detected", :blob => blob, :strategy => returning_strategy, :language => languages.first)
|
||||
|
||||
languages.first
|
||||
end
|
||||
end
|
||||
|
||||
# Public: Get all Languages
|
||||
@@ -191,7 +203,7 @@ module Linguist
|
||||
# Returns all matching Languages or [] if none were found.
|
||||
def self.find_by_extension(extname)
|
||||
extname = ".#{extname}" unless extname.start_with?(".")
|
||||
@extension_index[extname]
|
||||
@extension_index[extname.downcase]
|
||||
end
|
||||
|
||||
# DEPRECATED
|
||||
@@ -528,8 +540,8 @@ module Linguist
|
||||
|
||||
if extnames = extensions[name]
|
||||
extnames.each do |extname|
|
||||
if !options['extensions'].index { |x| x.end_with? extname }
|
||||
warn "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml" unless extname == '.script!'
|
||||
if !options['extensions'].index { |x| x.downcase.end_with? extname.downcase }
|
||||
warn "#{name} has a sample with extension (#{extname.downcase}) that isn't explicitly defined in languages.yml" unless extname == '.script!'
|
||||
options['extensions'] << extname
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,6 +41,14 @@ AGS Script:
|
||||
tm_scope: source.c++
|
||||
ace_mode: c_cpp
|
||||
|
||||
AMPL:
|
||||
type: programming
|
||||
color: "#00008B"
|
||||
extensions:
|
||||
- .ampl
|
||||
tm_scope: source.ampl
|
||||
ace_mode: text
|
||||
|
||||
ANTLR:
|
||||
type: programming
|
||||
color: "#9DC3FF"
|
||||
@@ -204,7 +212,6 @@ Assembly:
|
||||
- nasm
|
||||
extensions:
|
||||
- .asm
|
||||
- .ASM
|
||||
- .a51
|
||||
- .nasm
|
||||
tm_scope: source.asm.x86
|
||||
@@ -271,6 +278,7 @@ Batchfile:
|
||||
ace_mode: batchfile
|
||||
|
||||
Befunge:
|
||||
type: programming
|
||||
extensions:
|
||||
- .befunge
|
||||
ace_mode: text
|
||||
@@ -326,6 +334,7 @@ Boo:
|
||||
ace_mode: text
|
||||
|
||||
Brainfuck:
|
||||
type: programming
|
||||
extensions:
|
||||
- .b
|
||||
- .bf
|
||||
@@ -347,11 +356,9 @@ Bro:
|
||||
|
||||
C:
|
||||
type: programming
|
||||
color: "#555"
|
||||
color: "#555555"
|
||||
extensions:
|
||||
- .c
|
||||
- .C
|
||||
- .H
|
||||
- .cats
|
||||
- .h
|
||||
- .idc
|
||||
@@ -421,6 +428,7 @@ CLIPS:
|
||||
ace_mode: text
|
||||
|
||||
CMake:
|
||||
type: programming
|
||||
extensions:
|
||||
- .cmake
|
||||
- .cmake.in
|
||||
@@ -432,8 +440,6 @@ COBOL:
|
||||
type: programming
|
||||
extensions:
|
||||
- .cob
|
||||
- .COB
|
||||
- .CPY
|
||||
- .cbl
|
||||
- .ccp
|
||||
- .cobol
|
||||
@@ -480,6 +486,7 @@ Chapel:
|
||||
ace_mode: text
|
||||
|
||||
ChucK:
|
||||
type: programming
|
||||
extensions:
|
||||
- .ck
|
||||
tm_scope: source.java
|
||||
@@ -641,6 +648,7 @@ Crystal:
|
||||
- crystal
|
||||
|
||||
Cucumber:
|
||||
type: programming
|
||||
extensions:
|
||||
- .feature
|
||||
tm_scope: text.gherkin.feature
|
||||
@@ -699,7 +707,17 @@ DM:
|
||||
tm_scope: source.c++
|
||||
ace_mode: c_cpp
|
||||
|
||||
DTrace:
|
||||
type: programming
|
||||
extensions:
|
||||
- .d
|
||||
interpreters:
|
||||
- dtrace
|
||||
tm_scope: source.c
|
||||
ace_mode: c_cpp
|
||||
|
||||
Darcs Patch:
|
||||
type: programming
|
||||
search_term: dpatch
|
||||
aliases:
|
||||
- dpatch
|
||||
@@ -717,6 +735,7 @@ Dart:
|
||||
ace_mode: dart
|
||||
|
||||
Diff:
|
||||
type: programming
|
||||
extensions:
|
||||
- .diff
|
||||
- .patch
|
||||
@@ -872,14 +891,6 @@ FORTRAN:
|
||||
color: "#4d41b1"
|
||||
extensions:
|
||||
- .f90
|
||||
- .F
|
||||
- .F03
|
||||
- .F08
|
||||
- .F77
|
||||
- .F90
|
||||
- .F95
|
||||
- .FOR
|
||||
- .FPP
|
||||
- .f
|
||||
- .f03
|
||||
- .f08
|
||||
@@ -923,9 +934,7 @@ Forth:
|
||||
color: "#341708"
|
||||
extensions:
|
||||
- .fth
|
||||
- .4TH
|
||||
- .4th
|
||||
- .F
|
||||
- .f
|
||||
- .for
|
||||
- .forth
|
||||
@@ -974,7 +983,6 @@ GAS:
|
||||
group: Assembly
|
||||
extensions:
|
||||
- .s
|
||||
- .S
|
||||
tm_scope: source.asm.x86
|
||||
ace_mode: assembly_x86
|
||||
|
||||
@@ -986,7 +994,6 @@ GDScript:
|
||||
ace_mode: text
|
||||
|
||||
GLSL:
|
||||
group: C
|
||||
type: programming
|
||||
extensions:
|
||||
- .glsl
|
||||
@@ -1014,6 +1021,7 @@ Game Maker Language:
|
||||
ace_mode: c_cpp
|
||||
|
||||
Genshi:
|
||||
type: programming
|
||||
extensions:
|
||||
- .kid
|
||||
tm_scope: text.xml.genshi
|
||||
@@ -1023,6 +1031,7 @@ Genshi:
|
||||
ace_mode: xml
|
||||
|
||||
Gentoo Ebuild:
|
||||
type: programming
|
||||
group: Shell
|
||||
extensions:
|
||||
- .ebuild
|
||||
@@ -1030,6 +1039,7 @@ Gentoo Ebuild:
|
||||
ace_mode: sh
|
||||
|
||||
Gentoo Eclass:
|
||||
type: programming
|
||||
group: Shell
|
||||
extensions:
|
||||
- .eclass
|
||||
@@ -1037,6 +1047,7 @@ Gentoo Eclass:
|
||||
ace_mode: sh
|
||||
|
||||
Gettext Catalog:
|
||||
type: prose
|
||||
search_term: pot
|
||||
searchable: false
|
||||
aliases:
|
||||
@@ -1132,11 +1143,11 @@ Graphviz (DOT):
|
||||
tm_scope: source.dot
|
||||
extensions:
|
||||
- .dot
|
||||
- .DOT
|
||||
- .gv
|
||||
ace_mode: text
|
||||
|
||||
Groff:
|
||||
type: programming
|
||||
extensions:
|
||||
- .man
|
||||
- '.1'
|
||||
@@ -1164,6 +1175,7 @@ Groovy:
|
||||
- groovy
|
||||
|
||||
Groovy Server Pages:
|
||||
type: programming
|
||||
group: Groovy
|
||||
aliases:
|
||||
- gsp
|
||||
@@ -1313,6 +1325,7 @@ INI:
|
||||
- .ini
|
||||
- .cfg
|
||||
- .prefs
|
||||
- .pro
|
||||
- .properties
|
||||
tm_scope: source.ini
|
||||
aliases:
|
||||
@@ -1320,6 +1333,7 @@ INI:
|
||||
ace_mode: ini
|
||||
|
||||
IRC log:
|
||||
type: data
|
||||
search_term: irc
|
||||
aliases:
|
||||
- irc
|
||||
@@ -1350,6 +1364,7 @@ Inform 7:
|
||||
ace_mode: text
|
||||
|
||||
Inno Setup:
|
||||
type: programming
|
||||
extensions:
|
||||
- .iss
|
||||
tm_scope: source.inno
|
||||
@@ -1445,6 +1460,7 @@ Java:
|
||||
- .java
|
||||
|
||||
Java Server Pages:
|
||||
type: programming
|
||||
group: Java
|
||||
search_term: jsp
|
||||
aliases:
|
||||
@@ -1540,6 +1556,7 @@ LFE:
|
||||
ace_mode: lisp
|
||||
|
||||
LLVM:
|
||||
type: programming
|
||||
extensions:
|
||||
- .ll
|
||||
ace_mode: text
|
||||
@@ -1591,6 +1608,13 @@ Latte:
|
||||
tm_scope: source.smarty
|
||||
ace_mode: smarty
|
||||
|
||||
Lean:
|
||||
type: programming
|
||||
extensions:
|
||||
- .lean
|
||||
- .hlean
|
||||
ace_mode: lean
|
||||
|
||||
Less:
|
||||
type: markup
|
||||
group: CSS
|
||||
@@ -1600,6 +1624,7 @@ Less:
|
||||
ace_mode: less
|
||||
|
||||
LilyPond:
|
||||
type: programming
|
||||
extensions:
|
||||
- .ly
|
||||
- .ily
|
||||
@@ -1720,6 +1745,15 @@ MTML:
|
||||
tm_scope: text.html.basic
|
||||
ace_mode: html
|
||||
|
||||
MUF:
|
||||
type: programming
|
||||
group: Forth
|
||||
extensions:
|
||||
- .muf
|
||||
- .m
|
||||
tm_scope: none
|
||||
ace_mode: forth
|
||||
|
||||
Makefile:
|
||||
type: programming
|
||||
aliases:
|
||||
@@ -1728,6 +1762,7 @@ Makefile:
|
||||
- mf
|
||||
extensions:
|
||||
- .mak
|
||||
- .d
|
||||
- .mk
|
||||
filenames:
|
||||
- GNUmakefile
|
||||
@@ -1738,6 +1773,7 @@ Makefile:
|
||||
ace_mode: makefile
|
||||
|
||||
Mako:
|
||||
type: programming
|
||||
extensions:
|
||||
- .mako
|
||||
- .mao
|
||||
@@ -1774,6 +1810,8 @@ Mathematica:
|
||||
- .ma
|
||||
- .nb
|
||||
- .nbp
|
||||
- .wl
|
||||
- .wlt
|
||||
aliases:
|
||||
- mma
|
||||
ace_mode: text
|
||||
@@ -1830,6 +1868,7 @@ Mercury:
|
||||
ace_mode: prolog
|
||||
|
||||
MiniD: # Legacy
|
||||
type: programming
|
||||
searchable: false
|
||||
extensions:
|
||||
- .minid # Dummy extension
|
||||
@@ -1877,12 +1916,21 @@ MoonScript:
|
||||
ace_mode: text
|
||||
|
||||
Myghty:
|
||||
type: programming
|
||||
extensions:
|
||||
- .myt
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
|
||||
NL:
|
||||
type: data
|
||||
extensions:
|
||||
- .nl
|
||||
tm_scope: none
|
||||
ace_mode: text
|
||||
|
||||
NSIS:
|
||||
type: programming
|
||||
extensions:
|
||||
- .nsi
|
||||
- .nsh
|
||||
@@ -1974,6 +2022,7 @@ Nu:
|
||||
- nush
|
||||
|
||||
NumPy:
|
||||
type: programming
|
||||
group: Python
|
||||
extensions:
|
||||
- .numpy
|
||||
@@ -2087,7 +2136,7 @@ OpenSCAD:
|
||||
type: programming
|
||||
extensions:
|
||||
- .scad
|
||||
tm_scope: none
|
||||
tm_scope: source.scad
|
||||
ace_mode: scad
|
||||
|
||||
Org:
|
||||
@@ -2152,6 +2201,26 @@ PHP:
|
||||
aliases:
|
||||
- inc
|
||||
|
||||
#Oracle
|
||||
PLSQL:
|
||||
type: programming
|
||||
ace_mode: sql
|
||||
tm_scope: source.plsql.oracle
|
||||
extensions:
|
||||
- .pls
|
||||
- .pkb
|
||||
- .pks
|
||||
- .plb
|
||||
- .sql
|
||||
|
||||
#Postgres
|
||||
PLpgSQL:
|
||||
type: programming
|
||||
ace_mode: pgsql
|
||||
tm_scope: source.sql
|
||||
extensions:
|
||||
- .sql
|
||||
|
||||
Pan:
|
||||
type: programming
|
||||
color: '#cc0000'
|
||||
@@ -2217,7 +2286,6 @@ Perl:
|
||||
color: "#0298c3"
|
||||
extensions:
|
||||
- .pl
|
||||
- .PL
|
||||
- .cgi
|
||||
- .fcgi
|
||||
- .perl
|
||||
@@ -2425,7 +2493,7 @@ Python traceback:
|
||||
ace_mode: text
|
||||
|
||||
QML:
|
||||
type: markup
|
||||
type: programming
|
||||
color: "#44a51c"
|
||||
extensions:
|
||||
- .qml
|
||||
@@ -2433,6 +2501,7 @@ QML:
|
||||
ace_mode: text
|
||||
|
||||
QMake:
|
||||
type: programming
|
||||
extensions:
|
||||
- .pro
|
||||
- .pri
|
||||
@@ -2449,8 +2518,6 @@ R:
|
||||
- splus
|
||||
extensions:
|
||||
- .r
|
||||
- .R
|
||||
- .Rd
|
||||
- .rd
|
||||
- .rsx
|
||||
filenames:
|
||||
@@ -2503,7 +2570,6 @@ RMarkdown:
|
||||
ace_mode: markdown
|
||||
extensions:
|
||||
- .rmd
|
||||
- .Rmd
|
||||
tm_scope: none
|
||||
|
||||
Racket:
|
||||
@@ -2529,6 +2595,7 @@ Ragel in Ruby Host:
|
||||
ace_mode: text
|
||||
|
||||
Raw token data:
|
||||
type: data
|
||||
search_term: raw
|
||||
aliases:
|
||||
- raw
|
||||
@@ -2560,6 +2627,7 @@ Red:
|
||||
ace_mode: text
|
||||
|
||||
Redcode:
|
||||
type: programming
|
||||
extensions:
|
||||
- .cw
|
||||
tm_scope: none
|
||||
@@ -2598,6 +2666,7 @@ Ruby:
|
||||
- .gemspec
|
||||
- .god
|
||||
- .irbrc
|
||||
- .jbuilder
|
||||
- .mspec
|
||||
- .pluginspec
|
||||
- .podspec
|
||||
@@ -2682,6 +2751,15 @@ SQL:
|
||||
- .udf
|
||||
- .viw
|
||||
|
||||
#IBM DB2
|
||||
SQLPL:
|
||||
type: programming
|
||||
ace_mode: sql
|
||||
tm_scope: source.sql
|
||||
extensions:
|
||||
- .sql
|
||||
- .db2
|
||||
|
||||
STON:
|
||||
type: data
|
||||
group: Smalltalk
|
||||
@@ -2846,6 +2924,7 @@ Smalltalk:
|
||||
ace_mode: text
|
||||
|
||||
Smarty:
|
||||
type: programming
|
||||
extensions:
|
||||
- .tpl
|
||||
ace_mode: smarty
|
||||
@@ -2857,6 +2936,7 @@ SourcePawn:
|
||||
- sourcemod
|
||||
extensions:
|
||||
- .sp
|
||||
- .sma
|
||||
tm_scope: source.sp
|
||||
ace_mode: text
|
||||
|
||||
@@ -3068,11 +3148,11 @@ UnrealScript:
|
||||
|
||||
VCL:
|
||||
type: programming
|
||||
ace_mode: perl
|
||||
color: "#0298c3"
|
||||
extensions:
|
||||
- .vcl
|
||||
tm_scope: source.perl
|
||||
tm_scope: source.varnish.vcl
|
||||
ace_mode: text
|
||||
|
||||
VHDL:
|
||||
type: programming
|
||||
@@ -3162,9 +3242,10 @@ WebIDL:
|
||||
|
||||
XC:
|
||||
type: programming
|
||||
color: "#99DA07"
|
||||
extensions:
|
||||
- .xc
|
||||
tm_scope: source.c
|
||||
tm_scope: source.xc
|
||||
ace_mode: c_cpp
|
||||
|
||||
XML:
|
||||
@@ -3214,11 +3295,11 @@ XML:
|
||||
- .sublime-snippet
|
||||
- .targets
|
||||
- .tmCommand
|
||||
- .tml
|
||||
- .tmLanguage
|
||||
- .tmPreferences
|
||||
- .tmSnippet
|
||||
- .tmTheme
|
||||
- .tml
|
||||
- .ts
|
||||
- .ui
|
||||
- .urdf
|
||||
@@ -3269,6 +3350,7 @@ XQuery:
|
||||
ace_mode: xquery
|
||||
|
||||
XS:
|
||||
type: programming
|
||||
extensions:
|
||||
- .xs
|
||||
tm_scope: source.c
|
||||
@@ -3341,6 +3423,7 @@ desktop:
|
||||
|
||||
eC:
|
||||
type: programming
|
||||
color: "#4A4773"
|
||||
search_term: ec
|
||||
extensions:
|
||||
- .ec
|
||||
@@ -3365,6 +3448,7 @@ fish:
|
||||
ace_mode: text
|
||||
|
||||
mupad:
|
||||
type: programming
|
||||
extensions:
|
||||
- .mu
|
||||
ace_mode: text
|
||||
|
||||
@@ -9,21 +9,21 @@
|
||||
- CSS
|
||||
- Clojure
|
||||
- CoffeeScript
|
||||
- Common Lisp
|
||||
- Diff
|
||||
- Emacs Lisp
|
||||
- Erlang
|
||||
- Go
|
||||
- HTML
|
||||
- Haskell
|
||||
- Java
|
||||
- JavaScript
|
||||
- Lua
|
||||
- Matlab
|
||||
- Objective-C
|
||||
- PHP
|
||||
- Perl
|
||||
- Python
|
||||
- R
|
||||
- Ruby
|
||||
- SQL
|
||||
- Scala
|
||||
- Scheme
|
||||
- Shell
|
||||
- Swift
|
||||
- TeX
|
||||
- VimL
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module Linguist
|
||||
VERSION = "4.5.0b1"
|
||||
VERSION = "4.5.0b2"
|
||||
end
|
||||
|
||||
25
samples/AMPL/toy.ampl
Normal file
25
samples/AMPL/toy.ampl
Normal file
@@ -0,0 +1,25 @@
|
||||
# A toy knapsack problem from the LocalSolver docs written in AMPL.
|
||||
|
||||
set I;
|
||||
param Value{I};
|
||||
param Weight{I};
|
||||
param KnapsackBound;
|
||||
var Take{I} binary;
|
||||
|
||||
maximize TotalValue: sum{i in I} Take[i] * Value[i];
|
||||
s.t. WeightLimit: sum{i in I} Take[i] * Weight[i] <= KnapsackBound;
|
||||
|
||||
data;
|
||||
|
||||
param:
|
||||
I: Weight Value :=
|
||||
0 10 1
|
||||
1 60 10
|
||||
2 30 15
|
||||
3 40 40
|
||||
4 30 60
|
||||
5 20 90
|
||||
6 20 100
|
||||
7 2 15;
|
||||
|
||||
param KnapsackBound := 102;
|
||||
13
samples/Brainfuck/fib100.bf
Normal file
13
samples/Brainfuck/fib100.bf
Normal file
@@ -0,0 +1,13 @@
|
||||
# Calculate and output all fibonacci numbers under 100
|
||||
|
||||
+++++++++++
|
||||
>+>>>>++++++++++++++++++++++++++++++++++++++++++++
|
||||
>++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+>
|
||||
+<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[-
|
||||
<-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<<
|
||||
-]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]
|
||||
>[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++
|
||||
+++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++
|
||||
++++++++++++++++++++++++++++++++++++++++++++.[-]<<
|
||||
<<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<<
|
||||
[-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]
|
||||
4
samples/Brainfuck/hello.bf
Normal file
4
samples/Brainfuck/hello.bf
Normal file
@@ -0,0 +1,4 @@
|
||||
// More complex version of hello world
|
||||
|
||||
>++++++++[<+++++++++>-]<.>>+>+>++>[-]+<[>[->+<<++++>]<<]>.+++++++..+++.>
|
||||
>+++++++.<<<[[-]<[-]>]<+++++++++++++++.>>.+++.------.--------.>>+.>++++.
|
||||
3
samples/Brainfuck/helloworld.bf
Normal file
3
samples/Brainfuck/helloworld.bf
Normal file
@@ -0,0 +1,3 @@
|
||||
// Hello World
|
||||
|
||||
++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++..+++.>>.<-.<.+++.------.--------.>>+.>++.
|
||||
30
samples/Brainfuck/rot13.bf
Normal file
30
samples/Brainfuck/rot13.bf
Normal file
@@ -0,0 +1,30 @@
|
||||
# ROT13 cipher
|
||||
|
||||
-,+[ Read first character and start outer character reading loop
|
||||
-[ Skip forward if character is 0
|
||||
>>++++[>++++++++<-] Set up divisor (32) for division loop
|
||||
(MEMORY LAYOUT: dividend copy remainder divisor quotient zero zero)
|
||||
<+<-[ Set up dividend (x minus 1) and enter division loop
|
||||
>+>+>-[>>>] Increase copy and remainder / reduce divisor / Normal case: skip forward
|
||||
<[[>+<-]>>+>] Special case: move remainder back to divisor and increase quotient
|
||||
<<<<<- Decrement dividend
|
||||
] End division loop
|
||||
]>>>[-]+ End skip loop; zero former divisor and reuse space for a flag
|
||||
>--[-[<->+++[-]]]<[ Zero that flag unless quotient was 2 or 3; zero quotient; check flag
|
||||
++++++++++++<[ If flag then set up divisor (13) for second division loop
|
||||
(MEMORY LAYOUT: zero copy dividend divisor remainder quotient zero zero)
|
||||
>-[>+>>] Reduce divisor; Normal case: increase remainder
|
||||
>[+[<+>-]>+>>] Special case: increase remainder / move it back to divisor / increase quotient
|
||||
<<<<<- Decrease dividend
|
||||
] End division loop
|
||||
>>[<+>-] Add remainder back to divisor to get a useful 13
|
||||
>[ Skip forward if quotient was 0
|
||||
-[ Decrement quotient and skip forward if quotient was 1
|
||||
-<<[-]>> Zero quotient and divisor if quotient was 2
|
||||
]<<[<<->>-]>> Zero divisor and subtract 13 from copy if quotient was 1
|
||||
]<<[<<+>>-] Zero divisor and add 13 to copy if quotient was 0
|
||||
] End outer skip loop (jump to here if ((character minus 1)/32) was not 2 or 3)
|
||||
<[-] Clear remainder from first division if second division was skipped
|
||||
<.[-] Output ROT13ed character from copy and clear it
|
||||
<-,+ Read next character
|
||||
] End character reading loop
|
||||
166
samples/C/pqiv.h
Normal file
166
samples/C/pqiv.h
Normal file
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* pqiv
|
||||
*
|
||||
* Copyright (c) 2013-2014, Phillip Berndt
|
||||
*
|
||||
* This program 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.
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
// This file contains the definition of files, image types and
|
||||
// the plugin infrastructure. It should be included in file type
|
||||
// handlers.
|
||||
|
||||
#ifndef _PQIV_H_INCLUDED
|
||||
#define _PQIV_H_INCLUDED
|
||||
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gio/gio.h>
|
||||
#include "lib/bostree.h"
|
||||
|
||||
#ifndef PQIV_VERSION
|
||||
#define PQIV_VERSION "2.3"
|
||||
#endif
|
||||
|
||||
#define FILE_FLAGS_ANIMATION (guint)(1)
|
||||
#define FILE_FLAGS_MEMORY_IMAGE (guint)(1<<1)
|
||||
|
||||
// The structure for images {{{
|
||||
typedef struct file_type_handler_struct_t file_type_handler_t;
|
||||
typedef struct {
|
||||
// File type
|
||||
const file_type_handler_t *file_type;
|
||||
|
||||
// Special flags
|
||||
// FILE_FLAGS_ANIMATION -> Animation functions are invoked
|
||||
// Set by file type handlers
|
||||
// FILE_FLAGS_MEMORY_IMAGE -> File lives in memory
|
||||
guint file_flags;
|
||||
|
||||
// The file name to display and to sort by
|
||||
gchar *display_name;
|
||||
|
||||
// The URI or file name of the file
|
||||
gchar *file_name;
|
||||
|
||||
// If the file is a memory image, the actual image data
|
||||
GBytes *file_data;
|
||||
|
||||
// The file monitor structure is used for inotify-watching of
|
||||
// the files
|
||||
GFileMonitor *file_monitor;
|
||||
|
||||
// This flag stores whether this image is currently loaded
|
||||
// and valid. i.e. if it is set, you can assume that
|
||||
// private_data contains a representation of the image;
|
||||
// if not, you can NOT assume that it does not.
|
||||
gboolean is_loaded;
|
||||
|
||||
// Cached image size
|
||||
guint width;
|
||||
guint height;
|
||||
|
||||
// File-type specific data, allocated and freed by the file type handlers
|
||||
void *private;
|
||||
} file_t;
|
||||
// }}}
|
||||
// Definition of the built-in file types {{{
|
||||
|
||||
// If you want to implement your own file type, you'll have to implement the
|
||||
// following functions and a non-static initialization function named
|
||||
// file_type_NAME_initializer that fills a file_type_handler_t with pointers to
|
||||
// the functions. Store the file in backends/NAME.c and adjust the Makefile to
|
||||
// add the required libraries if your backend is listed in the $(BACKENDS)
|
||||
// variable.
|
||||
|
||||
typedef enum { PARAMETER, RECURSION, INOTIFY, BROWSE_ORIGINAL_PARAMETER, FILTER_OUTPUT } load_images_state_t;
|
||||
// Allocation function: Allocate the ->private structure within a file and add the
|
||||
// image(s) to the list of available images via load_images_handle_parameter_add_file()
|
||||
// If an image is not to be loaded for any reason, the file structure should be
|
||||
// deallocated using file_free()
|
||||
// Returns a pointer to the first added image
|
||||
// Optional, you can also set the pointer to this function to NULL.
|
||||
typedef BOSNode *(*file_type_alloc_fn_t)(load_images_state_t state, file_t *file);
|
||||
|
||||
// Deallocation, if a file is removed from the images list. Free the ->private structure.
|
||||
// Only called if ->private is non-NULL.
|
||||
typedef void (*file_type_free_fn_t)(file_t *file);
|
||||
|
||||
// Actually load a file into memory
|
||||
typedef void (*file_type_load_fn_t)(file_t *file, GInputStream *data, GError **error_pointer);
|
||||
|
||||
// Unload a file
|
||||
typedef void (*file_type_unload_fn_t)(file_t *file);
|
||||
|
||||
// Animation support: Initialize memory for animations, return ms until first frame
|
||||
// Optional, you can also set the pointer to this function to NULL.
|
||||
typedef double (*file_type_animation_initialize_fn_t)(file_t *file);
|
||||
|
||||
// Animation support: Advance to the next frame, return ms until next frame
|
||||
// Optional, you can also set the pointer to this function to NULL.
|
||||
typedef double (*file_type_animation_next_frame_fn_t)(file_t *file);
|
||||
|
||||
// Draw the current view to a cairo context
|
||||
typedef void (*file_type_draw_fn_t)(file_t *file, cairo_t *cr);
|
||||
|
||||
struct file_type_handler_struct_t {
|
||||
// All files will be filtered with this filter. If it lets it pass,
|
||||
// a handler is assigned to a file. If none do, the file is
|
||||
// discarded if it was found during directory traversal or
|
||||
// loaded using the first image backend if it was an explicit
|
||||
// parameter.
|
||||
GtkFileFilter *file_types_handled;
|
||||
|
||||
// Pointers to the functions defined above
|
||||
file_type_alloc_fn_t alloc_fn;
|
||||
file_type_free_fn_t free_fn;
|
||||
file_type_load_fn_t load_fn;
|
||||
file_type_unload_fn_t unload_fn;
|
||||
file_type_animation_initialize_fn_t animation_initialize_fn;
|
||||
file_type_animation_next_frame_fn_t animation_next_frame_fn;
|
||||
file_type_draw_fn_t draw_fn;
|
||||
};
|
||||
|
||||
// Initialization function: Tell pqiv about a backend
|
||||
typedef void (*file_type_initializer_fn_t)(file_type_handler_t *info);
|
||||
|
||||
// pqiv symbols available to plugins {{{
|
||||
|
||||
// Global cancellable that should be used for every i/o operation
|
||||
extern GCancellable *image_loader_cancellable;
|
||||
|
||||
// Current scale level. For backends that don't support cairo natively.
|
||||
extern gdouble current_scale_level;
|
||||
|
||||
// Load a file from disc/memory/network
|
||||
GInputStream *image_loader_stream_file(file_t *file, GError **error_pointer);
|
||||
|
||||
// Add a file to the list of loaded files
|
||||
// Should be called at least once in a file_type_alloc_fn_t, with the state being
|
||||
// forwarded unaltered.
|
||||
BOSNode *load_images_handle_parameter_add_file(load_images_state_t state, file_t *file);
|
||||
|
||||
// Load all data from an input stream into memory, conveinience function
|
||||
GBytes *g_input_stream_read_completely(GInputStream *input_stream, GCancellable *cancellable, GError **error_pointer);
|
||||
|
||||
// Free a file
|
||||
void file_free(file_t *file);
|
||||
|
||||
// }}}
|
||||
|
||||
// File type handlers, used in the initializer and file type guessing
|
||||
extern file_type_handler_t file_type_handlers[];
|
||||
|
||||
/* }}} */
|
||||
|
||||
#endif
|
||||
318
samples/D/mpq.d
Normal file
318
samples/D/mpq.d
Normal file
@@ -0,0 +1,318 @@
|
||||
/*
|
||||
* mpq.d -- D programming language module for libmpq
|
||||
*
|
||||
* Copyright (c) 2008 Georg Lukas <georg@op-co.de>
|
||||
*
|
||||
* This program 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 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* This module is written to support Phobos. Patches to allow binding to
|
||||
* Tango are welcome.
|
||||
*/
|
||||
|
||||
module mpq;
|
||||
|
||||
/* the following pragma does not work on DMD/Linux, generates a warning on
|
||||
* GDC/Linux and has not been tested on Windows. Commented out for now. */
|
||||
// pragma(lib, "libmpq");
|
||||
|
||||
import std.string; // for format() and toStringz()
|
||||
import std.traits; // for ParameterTypeTuple!()
|
||||
|
||||
/* XXX: this assumes that libmpq is compiled with Large File Support on */
|
||||
alias long off_t;
|
||||
|
||||
/* libmpq error return values */
|
||||
const LIBMPQ_ERROR_OPEN = -1; /* open error on file. */
|
||||
const LIBMPQ_ERROR_CLOSE = -2; /* close error on file. */
|
||||
const LIBMPQ_ERROR_SEEK = -3; /* lseek error on file. */
|
||||
const LIBMPQ_ERROR_READ = -4; /* read error on file. */
|
||||
const LIBMPQ_ERROR_WRITE = -5; /* write error on file. */
|
||||
const LIBMPQ_ERROR_MALLOC = -6; /* memory allocation error. */
|
||||
const LIBMPQ_ERROR_FORMAT = -7; /* format errror. */
|
||||
const LIBMPQ_ERROR_NOT_INITIALIZED = -8; /* init() wasn't called. */
|
||||
const LIBMPQ_ERROR_SIZE = -9; /* buffer size is to small. */
|
||||
const LIBMPQ_ERROR_EXIST = -10; /* file or block does not exist in archive. */
|
||||
const LIBMPQ_ERROR_DECRYPT = -11; /* we don't know the decryption seed. */
|
||||
const LIBMPQ_ERROR_UNPACK = -12; /* error on unpacking file. */
|
||||
|
||||
/** libmpq internal meta-data for an archive */
|
||||
extern struct mpq_archive_s;
|
||||
|
||||
extern(C) {
|
||||
|
||||
/* libmpq__generic information about library. */
|
||||
char *libmpq__version();
|
||||
|
||||
/* libmpq__generic mpq archive information. */
|
||||
int libmpq__archive_open(mpq_archive_s **mpq_archive, char *mpq_filename, off_t archive_offset);
|
||||
int libmpq__archive_close(mpq_archive_s *mpq_archive);
|
||||
int libmpq__archive_packed_size(mpq_archive_s *mpq_archive, off_t *packed_size);
|
||||
int libmpq__archive_unpacked_size(mpq_archive_s *mpq_archive, off_t *unpacked_size);
|
||||
int libmpq__archive_offset(mpq_archive_s *mpq_archive, off_t *offset);
|
||||
int libmpq__archive_version(mpq_archive_s *mpq_archive, uint *version_);
|
||||
int libmpq__archive_files(mpq_archive_s *mpq_archive, uint *files);
|
||||
|
||||
/* libmpq__generic file processing functions. */
|
||||
int libmpq__file_packed_size(mpq_archive_s *mpq_archive, uint file_number, off_t *packed_size);
|
||||
int libmpq__file_unpacked_size(mpq_archive_s *mpq_archive, uint file_number, off_t *unpacked_size);
|
||||
int libmpq__file_offset(mpq_archive_s *mpq_archive, uint file_number, off_t *offset);
|
||||
int libmpq__file_blocks(mpq_archive_s *mpq_archive, uint file_number, uint *blocks);
|
||||
int libmpq__file_encrypted(mpq_archive_s *mpq_archive, uint file_number, uint *encrypted);
|
||||
int libmpq__file_compressed(mpq_archive_s *mpq_archive, uint file_number, uint *compressed);
|
||||
int libmpq__file_imploded(mpq_archive_s *mpq_archive, uint file_number, uint *imploded);
|
||||
int libmpq__file_number(mpq_archive_s *mpq_archive, char *filename, uint *number);
|
||||
int libmpq__file_read(mpq_archive_s *mpq_archive, uint file_number, ubyte *out_buf, off_t out_size, off_t *transferred);
|
||||
|
||||
/* libmpq__generic block processing functions. */
|
||||
int libmpq__block_open_offset(mpq_archive_s *mpq_archive, uint file_number);
|
||||
int libmpq__block_close_offset(mpq_archive_s *mpq_archive, uint file_number);
|
||||
int libmpq__block_unpacked_size(mpq_archive_s *mpq_archive, uint file_number, uint block_number, off_t *unpacked_size);
|
||||
int libmpq__block_read(mpq_archive_s *mpq_archive, uint file_number, uint block_number, ubyte *out_buf, off_t out_size, off_t *transferred);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** exception class for failed libmpq calls */
|
||||
class MPQException : Exception {
|
||||
const string[] Errors = [
|
||||
"unknown error",
|
||||
"open error on file",
|
||||
"close error on file",
|
||||
"lseek error on file",
|
||||
"read error on file",
|
||||
"write error on file",
|
||||
"memory allocation error",
|
||||
"format errror",
|
||||
"init() wasn't called",
|
||||
"buffer size is to small",
|
||||
"file or block does not exist in archive",
|
||||
"we don't know the decryption seed",
|
||||
"error on unpacking file"];
|
||||
|
||||
public int errno;
|
||||
this(char[] fnname = "unknown_function", int errno = 0) {
|
||||
|
||||
this.errno = errno;
|
||||
if (-errno >= Errors.length)
|
||||
errno = 0;
|
||||
super(std.string.format("Error in %s(): %s (%d)",
|
||||
fnname, Errors[-errno], errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** template to wrap function calls and throw exceptions in case of error
|
||||
*
|
||||
* thanks for the idea to while(nan) blog,
|
||||
* http://while-nan.blogspot.com/2007/06/wrapping-functions-for-fun-and-profit.html
|
||||
*
|
||||
* use: MPQ_CHECKERR(libmpq__archive_open)(&m, "foo.mpq", -1);
|
||||
* returns the retval of archive_open on success;
|
||||
* throws an MPQException on failure.
|
||||
*
|
||||
* @param Fn libmpq__function reference
|
||||
* @param args libmpq__function parameters
|
||||
* @return return value of libmpq__function on success
|
||||
* @throw MPQException on error
|
||||
*/
|
||||
int MPQ_CHECKERR(alias Fn)(ParameterTypeTuple!(Fn) args)
|
||||
{
|
||||
int result = Fn(args);
|
||||
if (result < 0) {
|
||||
/* XXX: relying on non-specified stringof() behaviour */
|
||||
throw new MPQException((&Fn).stringof[2..$], result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** mixin alias to wrap library functions into MPQ_CHECKERR.
|
||||
*
|
||||
* alias mpq.func_name(...) to MPQ_CHECKERR(libmpq__func_name)(...)
|
||||
* @param func_name name of the function to be wrapped
|
||||
*/
|
||||
template MPQ_FUNC(char[] func_name) {
|
||||
const char[] MPQ_FUNC = "alias MPQ_CHECKERR!(libmpq__" ~ func_name ~ ") " ~ func_name ~ ";";
|
||||
}
|
||||
|
||||
alias libmpq__version libversion; /* must be direct alias because it returns char*, not error int */
|
||||
mixin(MPQ_FUNC!("archive_open"));
|
||||
mixin(MPQ_FUNC!("archive_close"));
|
||||
mixin(MPQ_FUNC!("archive_packed_size"));
|
||||
mixin(MPQ_FUNC!("archive_unpacked_size"));
|
||||
mixin(MPQ_FUNC!("archive_offset"));
|
||||
mixin(MPQ_FUNC!("archive_version"));
|
||||
mixin(MPQ_FUNC!("archive_files"));
|
||||
mixin(MPQ_FUNC!("file_packed_size"));
|
||||
mixin(MPQ_FUNC!("file_unpacked_size"));
|
||||
mixin(MPQ_FUNC!("file_offset"));
|
||||
mixin(MPQ_FUNC!("file_blocks"));
|
||||
mixin(MPQ_FUNC!("file_encrypted"));
|
||||
mixin(MPQ_FUNC!("file_compressed"));
|
||||
mixin(MPQ_FUNC!("file_imploded"));
|
||||
mixin(MPQ_FUNC!("file_number"));
|
||||
mixin(MPQ_FUNC!("file_read"));
|
||||
mixin(MPQ_FUNC!("block_open_offset"));
|
||||
mixin(MPQ_FUNC!("block_close_offset"));
|
||||
mixin(MPQ_FUNC!("block_unpacked_size"));
|
||||
mixin(MPQ_FUNC!("block_read"));
|
||||
|
||||
/** getter function named name for returning archive_* single values:
|
||||
*
|
||||
* <type> Archive.<name>() { return libmpq__archive_<name>() }
|
||||
*
|
||||
* @param type return type for the original function reference
|
||||
* @param name name of the original function
|
||||
* @param name2 name for the prototype (defaults to name, used for "version")
|
||||
* @return getter function mixin
|
||||
*/
|
||||
template MPQ_A_GET(char[] type, char[] name, char[] name2 = name) {
|
||||
const char[] MPQ_A_GET = type ~ " " ~ name2 ~ "() { " ~
|
||||
type ~ " ret; " ~
|
||||
"archive_" ~ name ~ "(m, &ret); return ret;" ~
|
||||
"}";
|
||||
}
|
||||
|
||||
/** wrapper class for an MPQ Archive
|
||||
*
|
||||
* syntax: auto a = new mpq.Archive("somefile.mpq");
|
||||
*/
|
||||
class Archive {
|
||||
mpq_archive_s *m;
|
||||
File listfile;
|
||||
char[][] listfiledata;
|
||||
|
||||
this(char[] archivename, off_t offset = -1) {
|
||||
archive_open(&m, toStringz(archivename), offset);
|
||||
}
|
||||
|
||||
mixin(MPQ_A_GET!("off_t", "packed_size"));
|
||||
mixin(MPQ_A_GET!("off_t", "unpacked_size"));
|
||||
mixin(MPQ_A_GET!("off_t", "offset"));
|
||||
mixin(MPQ_A_GET!("uint", "version", "version_"));
|
||||
mixin(MPQ_A_GET!("uint", "files"));
|
||||
|
||||
~this() {
|
||||
archive_close(m);
|
||||
}
|
||||
|
||||
mpq_archive_s* archive() {
|
||||
return m;
|
||||
}
|
||||
|
||||
File opIndex(char[] fname) {
|
||||
return new File(this, fname);
|
||||
}
|
||||
File opIndex(int fno) {
|
||||
return new File(this, fno);
|
||||
}
|
||||
|
||||
char[][] filelist() {
|
||||
try {
|
||||
if (!listfile) {
|
||||
listfile = this["(listfile)"];
|
||||
listfiledata = (cast(char[])listfile.read()).splitlines();
|
||||
}
|
||||
return listfiledata;
|
||||
} catch (MPQException e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/+uint filenumber(char[] filename) {
|
||||
try {
|
||||
if (!listfile) {
|
||||
listfile = this["(listfile)"];
|
||||
listfiledata = (cast(char[])listfile.read()).splitlines();
|
||||
}
|
||||
return listfiledata;
|
||||
} catch (MPQException e) {
|
||||
return [];
|
||||
}
|
||||
}+/
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** getter function named name for returning file_* single values:
|
||||
*
|
||||
* <type> File.<name>() { return libmpq__file_<name>() }
|
||||
*
|
||||
* @param type return type for the original function reference
|
||||
* @param name name of the original function
|
||||
* @param name2 name for the prototype (defaults to name, used for "version")
|
||||
* @return getter function mixin
|
||||
*/
|
||||
template MPQ_F_GET(char[] type, char[] name, char[] name2 = name) {
|
||||
const char[] MPQ_F_GET = type ~ " " ~ name2 ~ "() { " ~
|
||||
type ~ " ret; " ~
|
||||
"file_" ~ name ~ "(am, fileno, &ret); " ~
|
||||
"return ret;" ~
|
||||
"}";
|
||||
}
|
||||
|
||||
/** wrapper class for a single file in an MPQ Archive
|
||||
*
|
||||
* syntax:
|
||||
* auto a = new mpq.Archive("somefile.mpq");
|
||||
* auto f = a["(listfile)"];
|
||||
* auto f2 = a[0];
|
||||
* auto f3 = new File(a, "(listfile)");
|
||||
*/
|
||||
class File {
|
||||
Archive a;
|
||||
mpq_archive_s* am;
|
||||
char[] filename;
|
||||
uint fileno;
|
||||
|
||||
this(Archive a, int fileno) {
|
||||
this.a = a;
|
||||
this.am = a.archive();
|
||||
if (fileno >= a.files) {
|
||||
throw new MPQException(format("File(%d)", fileno),
|
||||
LIBMPQ_ERROR_EXIST);
|
||||
}
|
||||
this.filename = format("file%04d.xxx", fileno);
|
||||
this.fileno = fileno;
|
||||
}
|
||||
|
||||
this(Archive a, char[] filename) {
|
||||
this.a = a;
|
||||
this.am = a.archive();
|
||||
this.filename = filename;
|
||||
/* this line will throw an exception when the file is not there */
|
||||
mpq.file_number(am, toStringz(filename), &this.fileno);
|
||||
}
|
||||
|
||||
mixin(MPQ_F_GET!("off_t", "packed_size"));
|
||||
mixin(MPQ_F_GET!("off_t", "unpacked_size"));
|
||||
mixin(MPQ_F_GET!("off_t", "offset"));
|
||||
mixin(MPQ_F_GET!("uint", "blocks"));
|
||||
mixin(MPQ_F_GET!("uint", "encrypted"));
|
||||
mixin(MPQ_F_GET!("uint", "compressed"));
|
||||
mixin(MPQ_F_GET!("uint", "imploded"));
|
||||
|
||||
uint no() { return fileno; }
|
||||
char[] name() { return filename; }
|
||||
|
||||
ubyte[] read() {
|
||||
ubyte[] content;
|
||||
content.length = this.unpacked_size();
|
||||
off_t trans;
|
||||
mpq.file_read(am, fileno, content.ptr, content.length, &trans);
|
||||
content.length = trans;
|
||||
return content;
|
||||
}
|
||||
}
|
||||
23
samples/DTrace/counts.d
Normal file
23
samples/DTrace/counts.d
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* This software is in the public domain.
|
||||
*
|
||||
* $Id: counts.d 10510 2005-08-15 01:46:19Z kateturner $
|
||||
*/
|
||||
|
||||
#pragma D option quiet
|
||||
|
||||
self int tottime;
|
||||
BEGIN {
|
||||
tottime = timestamp;
|
||||
}
|
||||
|
||||
php$target:::function-entry
|
||||
@counts[copyinstr(arg0)] = count();
|
||||
}
|
||||
|
||||
END {
|
||||
printf("Total time: %dus\n", (timestamp - tottime) / 1000);
|
||||
printf("# calls by function:\n");
|
||||
printa("%-40s %@d\n", @counts);
|
||||
}
|
||||
|
||||
73
samples/DTrace/javascript-trace.d
Normal file
73
samples/DTrace/javascript-trace.d
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* Copyright (C) 2007 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* javascript provider probes
|
||||
*
|
||||
* function-entry (filename, classname, funcname)
|
||||
* function-info (filename, classname, funcname, lineno,
|
||||
* runfilename, runlineno)
|
||||
* function-args (filename, classname, funcname, argc, argv, argv0,
|
||||
* argv1, argv2, argv3, argv4)
|
||||
* function-rval (filename, classname, funcname, lineno, rval, rval0)
|
||||
* function-return (filename, classname, funcname)
|
||||
* object-create-start (filename, classname)
|
||||
* object-create (filename, classname, *object, rlineno)
|
||||
* object-create-done (filename, classname)
|
||||
* object-finalize (NULL, classname, *object)
|
||||
* execute-start (filename, lineno)
|
||||
* execute-done (filename, lineno)
|
||||
*/
|
||||
|
||||
provider javascript {
|
||||
probe function__entry(char *, char *, char *);
|
||||
probe function__info(char *, char *, char *, int, char *, int);
|
||||
probe function__args(char *, char *, char *, int, void *, void *, void *,
|
||||
void *, void *, void *);
|
||||
probe function__rval(char *, char *, char *, int, void *, void *);
|
||||
probe function__return(char *, char *, char *);
|
||||
probe object__create__start(char *, char *);
|
||||
probe object__create__done(char *, char *);
|
||||
/* XXX must use unsigned longs here instead of uintptr_t for OS X
|
||||
(Apple radar: 5194316 & 5565198) */
|
||||
probe object__create(char *, char *, unsigned long, int);
|
||||
probe object__finalize(char *, char *, unsigned long);
|
||||
probe execute__start(char *, int);
|
||||
probe execute__done(char *, int);
|
||||
};
|
||||
|
||||
/*
|
||||
#pragma D attributes Unstable/Unstable/Common provider mozilla provider
|
||||
#pragma D attributes Private/Private/Unknown provider mozilla module
|
||||
#pragma D attributes Private/Private/Unknown provider mozilla function
|
||||
#pragma D attributes Unstable/Unstable/Common provider mozilla name
|
||||
#pragma D attributes Unstable/Unstable/Common provider mozilla args
|
||||
*/
|
||||
|
||||
93
samples/DTrace/probes.d
Normal file
93
samples/DTrace/probes.d
Normal file
@@ -0,0 +1,93 @@
|
||||
/* ----------
|
||||
* DTrace probes for PostgreSQL backend
|
||||
*
|
||||
* Copyright (c) 2006-2009, PostgreSQL Global Development Group
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/utils/probes.d,v 1.11 2009/04/02 20:59:10 momjian Exp $
|
||||
* ----------
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Typedefs used in PostgreSQL.
|
||||
*
|
||||
* NOTE: Do not use system-provided typedefs (e.g. uintptr_t, uint32_t, etc)
|
||||
* in probe definitions, as they cause compilation errors on Mac OS X 10.5.
|
||||
*/
|
||||
#define LocalTransactionId unsigned int
|
||||
#define LWLockId int
|
||||
#define LWLockMode int
|
||||
#define LOCKMODE int
|
||||
#define BlockNumber unsigned int
|
||||
#define Oid unsigned int
|
||||
#define ForkNumber int
|
||||
#define bool char
|
||||
|
||||
provider postgresql {
|
||||
|
||||
probe transaction__start(LocalTransactionId);
|
||||
probe transaction__commit(LocalTransactionId);
|
||||
probe transaction__abort(LocalTransactionId);
|
||||
|
||||
probe lwlock__acquire(LWLockId, LWLockMode);
|
||||
probe lwlock__release(LWLockId);
|
||||
probe lwlock__wait__start(LWLockId, LWLockMode);
|
||||
probe lwlock__wait__done(LWLockId, LWLockMode);
|
||||
probe lwlock__condacquire(LWLockId, LWLockMode);
|
||||
probe lwlock__condacquire__fail(LWLockId, LWLockMode);
|
||||
|
||||
probe lock__wait__start(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE);
|
||||
probe lock__wait__done(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, LOCKMODE);
|
||||
|
||||
probe query__parse__start(const char *);
|
||||
probe query__parse__done(const char *);
|
||||
probe query__rewrite__start(const char *);
|
||||
probe query__rewrite__done(const char *);
|
||||
probe query__plan__start();
|
||||
probe query__plan__done();
|
||||
probe query__execute__start();
|
||||
probe query__execute__done();
|
||||
probe query__start(const char *);
|
||||
probe query__done(const char *);
|
||||
probe statement__status(const char *);
|
||||
|
||||
probe sort__start(int, bool, int, int, bool);
|
||||
probe sort__done(bool, long);
|
||||
|
||||
probe buffer__read__start(ForkNumber, BlockNumber, Oid, Oid, Oid, bool, bool);
|
||||
probe buffer__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, bool, bool, bool);
|
||||
probe buffer__flush__start(ForkNumber, BlockNumber, Oid, Oid, Oid);
|
||||
probe buffer__flush__done(ForkNumber, BlockNumber, Oid, Oid, Oid);
|
||||
|
||||
probe buffer__checkpoint__start(int);
|
||||
probe buffer__checkpoint__sync__start();
|
||||
probe buffer__checkpoint__done();
|
||||
probe buffer__sync__start(int, int);
|
||||
probe buffer__sync__written(int);
|
||||
probe buffer__sync__done(int, int, int);
|
||||
probe buffer__write__dirty__start(ForkNumber, BlockNumber, Oid, Oid, Oid);
|
||||
probe buffer__write__dirty__done(ForkNumber, BlockNumber, Oid, Oid, Oid);
|
||||
|
||||
probe deadlock__found();
|
||||
|
||||
probe checkpoint__start(int);
|
||||
probe checkpoint__done(int, int, int, int, int);
|
||||
probe clog__checkpoint__start(bool);
|
||||
probe clog__checkpoint__done(bool);
|
||||
probe subtrans__checkpoint__start(bool);
|
||||
probe subtrans__checkpoint__done(bool);
|
||||
probe multixact__checkpoint__start(bool);
|
||||
probe multixact__checkpoint__done(bool);
|
||||
probe twophase__checkpoint__start();
|
||||
probe twophase__checkpoint__done();
|
||||
|
||||
probe smgr__md__read__start(ForkNumber, BlockNumber, Oid, Oid, Oid);
|
||||
probe smgr__md__read__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int);
|
||||
probe smgr__md__write__start(ForkNumber, BlockNumber, Oid, Oid, Oid);
|
||||
probe smgr__md__write__done(ForkNumber, BlockNumber, Oid, Oid, Oid, int, int);
|
||||
|
||||
probe xlog__insert(unsigned char, unsigned char);
|
||||
probe xlog__switch();
|
||||
probe wal__buffer__write__dirty__start();
|
||||
probe wal__buffer__write__dirty__done();
|
||||
};
|
||||
44
samples/Eiffel/application.e
Normal file
44
samples/Eiffel/application.e
Normal file
@@ -0,0 +1,44 @@
|
||||
note
|
||||
description : "nino application root class"
|
||||
date : "$Date$"
|
||||
revision : "$Revision$"
|
||||
|
||||
class
|
||||
APPLICATION
|
||||
|
||||
inherit
|
||||
ARGUMENTS
|
||||
|
||||
HTTP_SERVER_SHARED_CONFIGURATION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Run application.
|
||||
local
|
||||
l_server : HTTP_SERVER
|
||||
l_cfg: HTTP_SERVER_CONFIGURATION
|
||||
l_http_handler : HTTP_HANDLER
|
||||
do
|
||||
create l_cfg.make
|
||||
l_cfg.http_server_port := 9_000
|
||||
l_cfg.document_root := default_document_root
|
||||
set_server_configuration (l_cfg)
|
||||
debug ("nino")
|
||||
l_cfg.set_is_verbose (True)
|
||||
end
|
||||
|
||||
create l_server.make (l_cfg)
|
||||
create {APPLICATION_CONNECTION_HANDLER} l_http_handler.make (l_server)
|
||||
l_server.setup (l_http_handler)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
default_document_root: STRING = "webroot"
|
||||
|
||||
end
|
||||
|
||||
82
samples/Eiffel/book_collection.e
Normal file
82
samples/Eiffel/book_collection.e
Normal file
@@ -0,0 +1,82 @@
|
||||
class
|
||||
BOOK_COLLECTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: STRING_32)
|
||||
-- Create a book collection with `a_name' as `name'.
|
||||
do
|
||||
set_name (a_name)
|
||||
create book_index.make (10)
|
||||
ensure
|
||||
name_set: name = a_name
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING_32
|
||||
-- Name.
|
||||
|
||||
books: LIST [BOOK]
|
||||
-- collection of book.
|
||||
do
|
||||
create {LINKED_LIST [BOOK]} Result.make
|
||||
across
|
||||
book_index as it
|
||||
loop
|
||||
Result.append (it.item)
|
||||
end
|
||||
end
|
||||
|
||||
books_by_author (a_author: STRING_32): LIST [BOOK]
|
||||
-- Books wrote by `a_author' in this collection.
|
||||
do
|
||||
if attached book_index [a_author] as l_result then
|
||||
Result := l_result
|
||||
else
|
||||
create {LINKED_LIST [BOOK]} Result.make
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_name (a_name: STRING_32)
|
||||
-- Set `name' with `a_name'.
|
||||
do
|
||||
name := a_name
|
||||
ensure
|
||||
name_set: name = a_name
|
||||
end
|
||||
|
||||
add_book (a_book: BOOK)
|
||||
-- Extend collection with `a_book'.
|
||||
local
|
||||
l: detachable LIST [BOOK]
|
||||
do
|
||||
l := book_index.at (a_book.author.name)
|
||||
if l = Void then
|
||||
create {LINKED_LIST [BOOK]} l.make
|
||||
book_index.put (l, a_book.author.name)
|
||||
end
|
||||
l.force (a_book)
|
||||
end
|
||||
|
||||
add_books (book_list: like books)
|
||||
-- Append collection with `book_list'.
|
||||
do
|
||||
across
|
||||
book_list as it
|
||||
loop
|
||||
add_book (it.item)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
book_index: HASH_TABLE [LIST [BOOK], STRING_32]
|
||||
-- Association of author name and its books.
|
||||
|
||||
end -- class BOOK_COLLECTION
|
||||
41
samples/Eiffel/git_checkout_command.e
Normal file
41
samples/Eiffel/git_checkout_command.e
Normal file
@@ -0,0 +1,41 @@
|
||||
note
|
||||
description: "Git checkout command."
|
||||
author: "Olivier Ligot"
|
||||
|
||||
class
|
||||
GIT_CHECKOUT_COMMAND
|
||||
|
||||
inherit
|
||||
GIT_COMMAND
|
||||
|
||||
create
|
||||
make,
|
||||
make_master
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_branch: STRING)
|
||||
-- Checkout the branch `a_branch'.
|
||||
do
|
||||
initialize
|
||||
arguments.force_last (a_branch)
|
||||
branch := a_branch
|
||||
ensure
|
||||
branch_set: branch = a_branch
|
||||
end
|
||||
|
||||
make_master
|
||||
-- Checkout the master branch.
|
||||
do
|
||||
make ("master")
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
branch: STRING
|
||||
-- Branch to checkout
|
||||
|
||||
name: STRING = "checkout"
|
||||
-- Git subcommand name
|
||||
|
||||
end
|
||||
71
samples/INI/MouseKeyboard.pro
Normal file
71
samples/INI/MouseKeyboard.pro
Normal file
@@ -0,0 +1,71 @@
|
||||
update=Sun 15 Feb 2015 01:10:10 PM EST
|
||||
last_client=eeschema
|
||||
[pcbnew]
|
||||
version=1
|
||||
PageLayoutDescrFile=
|
||||
LastNetListRead=
|
||||
UseCmpFile=1
|
||||
PadDrill=0.6
|
||||
PadDrillOvalY=0.6
|
||||
PadSizeH=1.5
|
||||
PadSizeV=1.5
|
||||
PcbTextSizeV=1.5
|
||||
PcbTextSizeH=1.5
|
||||
PcbTextThickness=0.3
|
||||
ModuleTextSizeV=1
|
||||
ModuleTextSizeH=1
|
||||
ModuleTextSizeThickness=0.15
|
||||
SolderMaskClearance=0
|
||||
SolderMaskMinWidth=0
|
||||
DrawSegmentWidth=0.2
|
||||
BoardOutlineThickness=0.09999999999999999
|
||||
ModuleOutlineThickness=0.15
|
||||
[pcbnew/libraries]
|
||||
LibDir=
|
||||
[general]
|
||||
version=1
|
||||
[eeschema]
|
||||
version=1
|
||||
PageLayoutDescrFile=
|
||||
SubpartIdSeparator=0
|
||||
SubpartFirstId=65
|
||||
LibDir=/home/hschmale/KiCad/LibMods-3rdParty
|
||||
NetFmtName=
|
||||
RptD_X=0
|
||||
RptD_Y=100
|
||||
RptLab=1
|
||||
LabSize=60
|
||||
[eeschema/libraries]
|
||||
LibName1=power
|
||||
LibName2=device
|
||||
LibName3=transistors
|
||||
LibName4=conn
|
||||
LibName5=linear
|
||||
LibName6=regul
|
||||
LibName7=74xx
|
||||
LibName8=cmos4000
|
||||
LibName9=adc-dac
|
||||
LibName10=memory
|
||||
LibName11=xilinx
|
||||
LibName12=special
|
||||
LibName13=microcontrollers
|
||||
LibName14=dsp
|
||||
LibName15=microchip
|
||||
LibName16=analog_switches
|
||||
LibName17=motorola
|
||||
LibName18=texas
|
||||
LibName19=intel
|
||||
LibName20=audio
|
||||
LibName21=interface
|
||||
LibName22=digital-audio
|
||||
LibName23=philips
|
||||
LibName24=display
|
||||
LibName25=cypress
|
||||
LibName26=siliconi
|
||||
LibName27=opto
|
||||
LibName28=atmel
|
||||
LibName29=contrib
|
||||
LibName30=valves
|
||||
LibName31=arduino_shieldsNCL
|
||||
LibName32=con-usb-2
|
||||
LibName33=2axispotwselect
|
||||
75
samples/Lean/binary.lean
Normal file
75
samples/Lean/binary.lean
Normal file
@@ -0,0 +1,75 @@
|
||||
/-
|
||||
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
||||
Released under Apache 2.0 license as described in the file LICENSE.
|
||||
|
||||
Module: algebra.binary
|
||||
Authors: Leonardo de Moura, Jeremy Avigad
|
||||
|
||||
General properties of binary operations.
|
||||
-/
|
||||
|
||||
import logic.eq
|
||||
open eq.ops
|
||||
|
||||
namespace binary
|
||||
section
|
||||
variable {A : Type}
|
||||
variables (op₁ : A → A → A) (inv : A → A) (one : A)
|
||||
|
||||
local notation a * b := op₁ a b
|
||||
local notation a ⁻¹ := inv a
|
||||
local notation 1 := one
|
||||
|
||||
definition commutative := ∀a b, a * b = b * a
|
||||
definition associative := ∀a b c, (a * b) * c = a * (b * c)
|
||||
definition left_identity := ∀a, 1 * a = a
|
||||
definition right_identity := ∀a, a * 1 = a
|
||||
definition left_inverse := ∀a, a⁻¹ * a = 1
|
||||
definition right_inverse := ∀a, a * a⁻¹ = 1
|
||||
definition left_cancelative := ∀a b c, a * b = a * c → b = c
|
||||
definition right_cancelative := ∀a b c, a * b = c * b → a = c
|
||||
|
||||
definition inv_op_cancel_left := ∀a b, a⁻¹ * (a * b) = b
|
||||
definition op_inv_cancel_left := ∀a b, a * (a⁻¹ * b) = b
|
||||
definition inv_op_cancel_right := ∀a b, a * b⁻¹ * b = a
|
||||
definition op_inv_cancel_right := ∀a b, a * b * b⁻¹ = a
|
||||
|
||||
variable (op₂ : A → A → A)
|
||||
|
||||
local notation a + b := op₂ a b
|
||||
|
||||
definition left_distributive := ∀a b c, a * (b + c) = a * b + a * c
|
||||
definition right_distributive := ∀a b c, (a + b) * c = a * c + b * c
|
||||
end
|
||||
|
||||
context
|
||||
variable {A : Type}
|
||||
variable {f : A → A → A}
|
||||
variable H_comm : commutative f
|
||||
variable H_assoc : associative f
|
||||
infixl `*` := f
|
||||
theorem left_comm : ∀a b c, a*(b*c) = b*(a*c) :=
|
||||
take a b c, calc
|
||||
a*(b*c) = (a*b)*c : H_assoc
|
||||
... = (b*a)*c : H_comm
|
||||
... = b*(a*c) : H_assoc
|
||||
|
||||
theorem right_comm : ∀a b c, (a*b)*c = (a*c)*b :=
|
||||
take a b c, calc
|
||||
(a*b)*c = a*(b*c) : H_assoc
|
||||
... = a*(c*b) : H_comm
|
||||
... = (a*c)*b : H_assoc
|
||||
end
|
||||
|
||||
context
|
||||
variable {A : Type}
|
||||
variable {f : A → A → A}
|
||||
variable H_assoc : associative f
|
||||
infixl `*` := f
|
||||
theorem assoc4helper (a b c d) : (a*b)*(c*d) = a*((b*c)*d) :=
|
||||
calc
|
||||
(a*b)*(c*d) = a*(b*(c*d)) : H_assoc
|
||||
... = a*((b*c)*d) : H_assoc
|
||||
end
|
||||
|
||||
end binary
|
||||
70
samples/Lean/set.hlean
Normal file
70
samples/Lean/set.hlean
Normal file
@@ -0,0 +1,70 @@
|
||||
-- Copyright (c) 2015 Jakob von Raumer. All rights reserved.
|
||||
-- Released under Apache 2.0 license as described in the file LICENSE.
|
||||
-- Authors: Jakob von Raumer
|
||||
-- Category of sets
|
||||
|
||||
import .basic types.pi trunc
|
||||
|
||||
open truncation sigma sigma.ops pi function eq morphism precategory
|
||||
open equiv
|
||||
|
||||
namespace precategory
|
||||
|
||||
universe variable l
|
||||
|
||||
definition set_precategory : precategory.{l+1 l} (Σ (A : Type.{l}), is_hset A) :=
|
||||
begin
|
||||
fapply precategory.mk.{l+1 l},
|
||||
intros, apply (a.1 → a_1.1),
|
||||
intros, apply trunc_pi, intros, apply b.2,
|
||||
intros, intro x, exact (a_1 (a_2 x)),
|
||||
intros, exact (λ (x : a.1), x),
|
||||
intros, apply funext.path_pi, intro x, apply idp,
|
||||
intros, apply funext.path_pi, intro x, apply idp,
|
||||
intros, apply funext.path_pi, intro x, apply idp,
|
||||
end
|
||||
|
||||
end precategory
|
||||
|
||||
namespace category
|
||||
|
||||
universe variable l
|
||||
local attribute precategory.set_precategory.{l+1 l} [instance]
|
||||
|
||||
definition set_category_equiv_iso (a b : (Σ (A : Type.{l}), is_hset A))
|
||||
: (a ≅ b) = (a.1 ≃ b.1) :=
|
||||
/-begin
|
||||
apply ua, fapply equiv.mk,
|
||||
intro H,
|
||||
apply (isomorphic.rec_on H), intros (H1, H2),
|
||||
apply (is_iso.rec_on H2), intros (H3, H4, H5),
|
||||
fapply equiv.mk,
|
||||
apply (isomorphic.rec_on H), intros (H1, H2),
|
||||
exact H1,
|
||||
fapply is_equiv.adjointify, exact H3,
|
||||
exact sorry,
|
||||
exact sorry,
|
||||
end-/ sorry
|
||||
|
||||
definition set_category : category.{l+1 l} (Σ (A : Type.{l}), is_hset A) :=
|
||||
/-begin
|
||||
assert (C : precategory.{l+1 l} (Σ (A : Type.{l}), is_hset A)),
|
||||
apply precategory.set_precategory,
|
||||
apply category.mk,
|
||||
assert (p : (λ A B p, (set_category_equiv_iso A B) ▹ iso_of_path p) = (λ A B p, @equiv_path A.1 B.1 p)),
|
||||
apply is_equiv.adjointify,
|
||||
intros,
|
||||
apply (isomorphic.rec_on a_1), intros (iso', is_iso'),
|
||||
apply (is_iso.rec_on is_iso'), intros (f', f'sect, f'retr),
|
||||
fapply sigma.path,
|
||||
apply ua, fapply equiv.mk, exact iso',
|
||||
fapply is_equiv.adjointify,
|
||||
exact f',
|
||||
intros, apply (f'retr ▹ _),
|
||||
intros, apply (f'sect ▹ _),
|
||||
apply (@is_hprop.elim),
|
||||
apply is_trunc_is_hprop,
|
||||
intros,
|
||||
end -/ sorry
|
||||
|
||||
end category
|
||||
278
samples/MUF/39.m
Normal file
278
samples/MUF/39.m
Normal file
@@ -0,0 +1,278 @@
|
||||
$include $lib/strings
|
||||
$include $lib/match
|
||||
lvar check-obj-addr
|
||||
|
||||
: check-next-loop (d -- )
|
||||
dup not if pop exit then
|
||||
dup exit? over thing? or
|
||||
me @ 3 pick .controls and if
|
||||
dup check-obj-addr @ execute
|
||||
then
|
||||
next check-next-loop
|
||||
;
|
||||
|
||||
: check-contents (d -- )
|
||||
contents check-next-loop
|
||||
;
|
||||
|
||||
: check-exits (d -- )
|
||||
exits check-next-loop
|
||||
;
|
||||
|
||||
: exec-err (d mtypestr warnstr -- )
|
||||
"On " 4 rotate unparseobj strcat
|
||||
", in it's " strcat rot strcat
|
||||
", " strcat swap strcat .tell
|
||||
;
|
||||
|
||||
: can-linkto? (player object -- i)
|
||||
dup "link_ok" flag? if pop pop 1 exit then
|
||||
.controls
|
||||
;
|
||||
|
||||
: check-exec (d mtype execstr -- )
|
||||
dup "@" 1 strncmp if pop pop pop exit then
|
||||
1 strcut swap pop
|
||||
" " .split pop
|
||||
dup "$" 1 strncmp not if
|
||||
dup match ok? not if
|
||||
" is not a known registered program." strcat
|
||||
exec-err exit
|
||||
then
|
||||
dup match program? not if
|
||||
" is not a program." strcat
|
||||
exec-err exit
|
||||
then
|
||||
3 pick owner over match can-linkto? not if
|
||||
" is not Link_OK." strcat
|
||||
exec-err exit
|
||||
then
|
||||
else
|
||||
dup number? not if
|
||||
" is not a program dbref." strcat
|
||||
"@" swap strcat exec-err exit
|
||||
then
|
||||
dup atoi dbref ok? not if
|
||||
" is not a valid program reference." strcat
|
||||
"@" swap strcat exec-err exit
|
||||
then
|
||||
dup atoi dbref program? not if
|
||||
" is not a valid program reference." strcat
|
||||
"@" swap strcat exec-err exit
|
||||
then
|
||||
3 pick owner over atoi dbref can-linkto? not if
|
||||
" is not Link_OK." strcat
|
||||
"@" swap strcat exec-err exit
|
||||
then
|
||||
then
|
||||
pop pop pop
|
||||
;
|
||||
|
||||
|
||||
: missing-err ( d s -- )
|
||||
swap unparseobj
|
||||
" is missing an "
|
||||
strcat swap strcat
|
||||
" message." strcat .tell
|
||||
;
|
||||
|
||||
: colon-err ( d s -- )
|
||||
swap unparseobj
|
||||
" has an unnecesary ':' at the start of its "
|
||||
strcat swap strcat
|
||||
" message." strcat .tell
|
||||
;
|
||||
|
||||
: check-desc (d -- )
|
||||
dup desc not if
|
||||
"@description" missing-err
|
||||
else
|
||||
"@description" over
|
||||
desc check-exec
|
||||
then
|
||||
;
|
||||
|
||||
: check-succ (d -- )
|
||||
dup succ not if
|
||||
"@success" missing-err
|
||||
else
|
||||
"@success" over
|
||||
succ check-exec
|
||||
then
|
||||
;
|
||||
|
||||
: check-fail (d -- )
|
||||
dup fail not if
|
||||
"@fail" missing-err
|
||||
else
|
||||
"@fail" over
|
||||
fail check-exec
|
||||
then
|
||||
;
|
||||
|
||||
: check-drop (d -- )
|
||||
dup drop not if
|
||||
"@drop" missing-err
|
||||
else
|
||||
"@drop" over
|
||||
drop check-exec
|
||||
then
|
||||
;
|
||||
|
||||
: check-osucc (d -- )
|
||||
dup osucc not if
|
||||
"@osuccess" missing-err
|
||||
else
|
||||
dup osucc ":" 1 strncmp not if
|
||||
"@osuccess" colon-err
|
||||
else pop
|
||||
then
|
||||
then
|
||||
;
|
||||
|
||||
: check-ofail (d -- )
|
||||
dup ofail not if
|
||||
"@ofail" missing-err
|
||||
else
|
||||
dup ofail ":" 1 strncmp not if
|
||||
"@ofail" colon-err
|
||||
else pop
|
||||
then
|
||||
then
|
||||
;
|
||||
|
||||
: check-odrop (d -- )
|
||||
dup odrop not if
|
||||
"@odrop" missing-err
|
||||
else
|
||||
dup odrop ":" 1 strncmp not if
|
||||
"@odrop" colon-err
|
||||
else pop
|
||||
then
|
||||
then
|
||||
;
|
||||
|
||||
|
||||
$define islocked? (d -- i) getlockstr "*UNLOCKED*" stringcmp $enddef
|
||||
|
||||
: islocked_always? (d -- i)
|
||||
getlockstr dup "#0" stringcmp not if pop 1 exit then
|
||||
dup "#" STRsplit swap pop atoi
|
||||
"#" swap intostr strcat
|
||||
(lockstr "#dbref")
|
||||
dup "&!" over strcat strcat
|
||||
3 pick stringcmp not if pop pop 1 exit then
|
||||
"&" over strcat strcat "!" swap strcat
|
||||
stringcmp not if 1 exit then
|
||||
0
|
||||
;
|
||||
|
||||
: check-link ( d -- )
|
||||
dup getlink not if
|
||||
dup unparseobj " is unlinked." strcat .tell
|
||||
else
|
||||
dup getlink over location dbcmp if
|
||||
dup islocked? not if
|
||||
dup unparseobj
|
||||
" is linked to it's location, but is unlocked."
|
||||
strcat .tell
|
||||
then
|
||||
else (is not linked to it's location)
|
||||
dup getlink program? if
|
||||
dup dup owner swap getlink can-linkto? not if
|
||||
dup unparseobj
|
||||
" is linked to a program which is not Link_OK."
|
||||
strcat .tell
|
||||
then
|
||||
then
|
||||
then
|
||||
then
|
||||
pop
|
||||
;
|
||||
|
||||
: check-room (d -- )
|
||||
dup check-desc
|
||||
dup islocked? if
|
||||
dup islocked_always? not if
|
||||
dup check-succ
|
||||
then
|
||||
dup check-fail
|
||||
then
|
||||
dup getlink if
|
||||
dup check-drop
|
||||
dup check-odrop
|
||||
then
|
||||
dup check-contents
|
||||
check-exits
|
||||
;
|
||||
|
||||
: check-exit ( d -- )
|
||||
dup check-link
|
||||
dup check-desc
|
||||
dup getlink dup ok? if
|
||||
program? not if
|
||||
dup islocked_always? not if
|
||||
dup check-succ
|
||||
dup check-osucc
|
||||
dup check-odrop
|
||||
then
|
||||
dup islocked? if
|
||||
dup check-fail
|
||||
dup check-ofail
|
||||
then
|
||||
then
|
||||
else pop
|
||||
then
|
||||
pop
|
||||
;
|
||||
|
||||
: check-thing ( d -- )
|
||||
dup check-desc
|
||||
dup islocked_always? not if
|
||||
dup check-succ
|
||||
dup check-osucc
|
||||
then
|
||||
dup islocked? if
|
||||
dup check-fail
|
||||
dup check-ofail
|
||||
then
|
||||
dup check-drop
|
||||
dup check-odrop
|
||||
check-exits
|
||||
;
|
||||
|
||||
: check-player ( d -- )
|
||||
dup check-desc
|
||||
dup islocked_always? not if
|
||||
dup check-succ
|
||||
dup check-osucc
|
||||
then
|
||||
dup islocked? if
|
||||
dup check-fail
|
||||
dup check-ofail
|
||||
then
|
||||
dup check-contents
|
||||
check-exits
|
||||
;
|
||||
|
||||
: check-program ( d -- )
|
||||
check-desc
|
||||
;
|
||||
|
||||
: check-obj (d -- )
|
||||
dup room? if check-room exit then
|
||||
dup exit? if check-exit exit then
|
||||
dup thing? if check-thing exit then
|
||||
dup player? if check-player exit then
|
||||
check-program
|
||||
;
|
||||
|
||||
: main
|
||||
'check-obj check-obj-addr !
|
||||
.strip dup not if pop "here" then
|
||||
.match_controlled
|
||||
dup #-3 dbcmp if pop me @ getlink then
|
||||
dup ok? not if pop exit then
|
||||
check-obj
|
||||
me @ "Check done." notify
|
||||
;
|
||||
275
samples/MUF/cmd-say.muf
Normal file
275
samples/MUF/cmd-say.muf
Normal file
@@ -0,0 +1,275 @@
|
||||
@program cmd-say.muf
|
||||
1 1000 d
|
||||
i
|
||||
( cmd-say.muf by Natasha@HLM
|
||||
|
||||
Copyright 2002-2004 Natasha Snunkmeox. Copyright 2002-2004 Here Lie Monsters.
|
||||
"@view $box/mit" for license information.
|
||||
)
|
||||
$author Natasha Snunkmeox <natmeox@neologasm.org>
|
||||
$note Say for Fuzzball 6.
|
||||
$version 1.0
|
||||
|
||||
$include $lib/ignore
|
||||
$include $lib/strings
|
||||
$include $lib/match
|
||||
|
||||
$def str_program "saypose"
|
||||
$def prop_third "_prefs/say/third"
|
||||
$def prop_quotes "_say/def/quotes"
|
||||
$def prop_overb "_say/def/osay"
|
||||
$def prop_verb "_say/def/say"
|
||||
$def prop_split "_prefs/say/split"
|
||||
$def prop_color "_prefs/say/color"
|
||||
$def prop_meow "_prefs/say/meow"
|
||||
|
||||
lvar randomWord
|
||||
|
||||
lvar verb
|
||||
lvar overb
|
||||
lvar lquo
|
||||
lvar rquo
|
||||
lvar splitsay
|
||||
|
||||
: rtn-getThirdVerb[ var:overb -- ]
|
||||
( Get the third-person verb. )
|
||||
me @ prop_overb getpropstr dup if ( str strOverb )
|
||||
strip dup dup "," instr not and if "," strcat then
|
||||
else pop "says," then ( str strOverb )
|
||||
me @ "%D %s" fmtstring overb @ ! ( str )
|
||||
;
|
||||
|
||||
: rtn-getFirstVerb[ var:verb var:overb -- ]
|
||||
me @ prop_third getpropstr .yes? not if ( str )
|
||||
( Get the first-person verb. )
|
||||
me @ prop_verb getpropstr dup if ( str strVerb )
|
||||
strip dup dup "," instr not and if "," strcat then
|
||||
else pop "say," then ( str strVerb )
|
||||
splitsay @ if "you %s" else "You %s" then fmtstring ( str strVerb )
|
||||
else overb @ @ then verb @ ! ( str )
|
||||
;
|
||||
|
||||
: rtn-getQuotes[ var:lquo var:rquo -- ]
|
||||
me @ prop_quotes getpropstr dup "%m" instr if ( strQuotes )
|
||||
"%m" split ( strLquo strRquo )
|
||||
else pop "\"" dup then ( strLquo strRquo )
|
||||
rquo @ ! lquo @ ! ( )
|
||||
;
|
||||
|
||||
: do-say ( str -- )
|
||||
"" randomWord !
|
||||
|
||||
var who
|
||||
var exclude
|
||||
|
||||
( Ignoring? Get 'em outta here. )
|
||||
loc @ contents_array ( str arrHere )
|
||||
dup me @ str_program array_get_ignorers ( str arrHere arrIgnorers )
|
||||
dup exclude !
|
||||
swap array_diff who !
|
||||
|
||||
|
||||
( Anyone #meowing this player? Go ahead and notify before special formatting. )
|
||||
who @ prop_meow me @ owner "*{%d}*" fmtstring array_filter_prop ( str arrMeow )
|
||||
dup if ( str arrMeow )
|
||||
dup who @ array_diff who ! ( str arrMeow )
|
||||
dup exclude @ array_union exclude ! ( str arrMeow )
|
||||
|
||||
over ansi_strip ( str arrMeow str )
|
||||
"\\b[A-Z0-9_]+\\b" "MEOW" REG_ALL regsub ( str arrMeow str' )
|
||||
"\\b[A-Z0-9_][A-Za-z0-9_]*[a-z][A-Za-z0-9_]*\\b" "Meow" REG_ALL regsub ( str arrMeow str' )
|
||||
"\\b[a-z_][A-Za-z0-9_]*\\b" "meow" REG_ALL regsub ( str arrMeow str' )
|
||||
me @ "%D meows, \"%s\"" fmtstring ( str arrMeow str" )
|
||||
1 array_make swap array_notify ( str )
|
||||
else pop then ( str )
|
||||
|
||||
|
||||
var msg
|
||||
|
||||
dup ",," instr ( str boolCommas )
|
||||
me @ prop_split getpropstr .no? not ( str boolCommas boolSplitOK )
|
||||
and if ( str )
|
||||
",," split ( str- -str )
|
||||
|
||||
( User-supplied verb? )
|
||||
dup ",," instr if
|
||||
",," split ( str- strVerb -str )
|
||||
swap dup if ( str- -str strVerb )
|
||||
strip ( str- -str strVerb )
|
||||
dup me @ name instr over tolower "%n" instr or if ( str- -str strVerb )
|
||||
"%n" "%N" subst me @ name "%n" subst ( str- -str strVerb )
|
||||
else
|
||||
me @ swap "%s %D," fmtstring ( str- -str -str- )
|
||||
then ( str- -str -str- )
|
||||
dup "*[-!.,:;]" smatch not if "," strcat then ( str- -str -str- )
|
||||
dup verb ! overb ! ( str- -str )
|
||||
else pop then ( str- -str )
|
||||
then ( str- -str )
|
||||
|
||||
2 array_make ( arrMsg )
|
||||
1
|
||||
else 0 then splitsay ! msg !
|
||||
|
||||
|
||||
verb @ string? not if
|
||||
overb rtn-getThirdVerb
|
||||
verb overb rtn-getFirstVerb
|
||||
then
|
||||
lquo rquo rtn-getQuotes ( str )
|
||||
|
||||
|
||||
( Say. )
|
||||
msg @ string? if
|
||||
rquo @ msg @ lquo @ ( strRquo strMsg strLquo )
|
||||
"%s %s%s%s" ( strRquo strMsg strLquo strFormat )
|
||||
|
||||
4 dupn
|
||||
verb @ swap fmtstring .tell ( strRquo strMsg strLquo strFormat )
|
||||
overb @ swap fmtstring ( strOsay )
|
||||
else
|
||||
rquo @ msg @ array_vals pop ( strRquo strMsg strMsg2 )
|
||||
swap dup "*[-!.,:;]" smatch not if "," strcat then swap ( strRquo strMsg strMsg2 )
|
||||
( Only handle strMsg if there's no strMsg2. )
|
||||
dup if ( strRquo strMsg strMsg2 )
|
||||
swap ( strRquo strMsg2 strMsg )
|
||||
lquo @ swap rquo @ swap lquo @ ( strRquo strMsg2 strLquo strRquo strMsg' strLquo )
|
||||
"%s%s%s %s %s%s%s" ( strRquo strMsg2 strLquo strRquo strMsg' strLquo strFormat )
|
||||
|
||||
7
|
||||
else ( strRquo strMsg strMsg2 )
|
||||
pop lquo @ ( strRquo strMsg' strLquo )
|
||||
"%s%s%s %s" ( strRquo strMsg' strLquo strFormat )
|
||||
|
||||
verb @ ",$" "." 0 regsub verb !
|
||||
overb @ ",$" "." 0 regsub overb !
|
||||
|
||||
4
|
||||
then ( ... strRquo strMsg strLquo strFormat intDepth )
|
||||
|
||||
dupn
|
||||
verb @ -5 rotate fmtstring .tell ( ... strRquo strMsg strLquo strFormat )
|
||||
overb @ -5 rotate fmtstring ( strOsay )
|
||||
then ( strOsay )
|
||||
|
||||
|
||||
( Is there color to avoid? )
|
||||
dup "\[[" instr if
|
||||
who @ prop_color "{n*|0}" array_filter_prop ( strOsay arrGreyed )
|
||||
dup if ( strOsay arrGreyed )
|
||||
over ansi_strip 1 array_make ( strOsay arrGreyed arrMsg )
|
||||
over array_notify ( strOsay arrGreyed )
|
||||
|
||||
exclude @ array_union exclude ! ( strOsay )
|
||||
else pop then ( strOsay )
|
||||
then ( strOsay )
|
||||
|
||||
loc @ ( strOsay db )
|
||||
exclude @ array_vals ( strOsay db dbExcludeN..dbExclude1 intN )
|
||||
me @ swap ++ ( strOsay db dbGreyedN..dbGreyed1' intN' )
|
||||
dup 3 + rotate ( db dbGreyedN..dbGreyed1 intN strOsay )
|
||||
notify_exclude ( )
|
||||
;
|
||||
|
||||
: do-help pop pop .showhelp ;
|
||||
: do-ignore pop str_program cmd-ignore-add ;
|
||||
: do-unignore pop str_program cmd-ignore-del ;
|
||||
|
||||
: do-third ( strY strZ -- )
|
||||
pop pop ( )
|
||||
me @ prop_third "yes" setprop
|
||||
me @ "You will see your own says in the third person (\"%D says\")." fmtstring .tellgood
|
||||
;
|
||||
: do-unthird ( strY strZ -- )
|
||||
pop pop ( )
|
||||
me @ prop_third remove_prop
|
||||
"You will see your own says in the second person (\"You say\")." .tellgood
|
||||
;
|
||||
|
||||
: do-grey ( strY strZ -- )
|
||||
pop pop ( )
|
||||
me @ prop_color "no" setprop
|
||||
me @ "You will not see color in any says. Note you will see color in your own says." fmtstring .tellgood
|
||||
;
|
||||
: do-ungrey ( strY strZ -- )
|
||||
pop pop ( )
|
||||
me @ prop_color remove_prop
|
||||
"You will see color in says." .tellgood
|
||||
;
|
||||
|
||||
: do-meow ( strY strZ -- )
|
||||
pop ( strY )
|
||||
dup if
|
||||
.noisy_pmatch dup ok? not if pop exit then ( db )
|
||||
me @ prop_meow 3 pick reflist_find if ( db )
|
||||
"%D is already in your #meow list." fmtstring .tellbad exit ( )
|
||||
then ( db )
|
||||
me @ prop_meow 3 pick reflist_add ( db )
|
||||
"%D added." fmtstring .tellgood
|
||||
else
|
||||
me @ prop_meow array_get_reflist ( arr )
|
||||
"" swap foreach swap pop "%D %s" fmtstring repeat
|
||||
"Your meowlist: " swap strcat .tellgood
|
||||
then
|
||||
;
|
||||
: do-unmeow ( strY strZ -- )
|
||||
pop ( strY )
|
||||
.noisy_pmatch dup ok? not if pop exit then ( db )
|
||||
me @ prop_meow 3 pick reflist_find not if ( db )
|
||||
"%D is not in your #meow list." fmtstring .tellbad exit ( )
|
||||
then ( db )
|
||||
me @ prop_meow 3 pick reflist_del ( db )
|
||||
"%D removed." fmtstring .tellgood
|
||||
;
|
||||
|
||||
$define dict_commands {
|
||||
"help" 'do-help
|
||||
"ignore" 'do-ignore
|
||||
"!ignore" 'do-unignore
|
||||
"meow" 'do-meow
|
||||
"!meow" 'do-unmeow
|
||||
"third" 'do-third
|
||||
"!third" 'do-unthird
|
||||
"grey" 'do-grey
|
||||
"gray" 'do-grey
|
||||
"!grey" 'do-ungrey
|
||||
"!gray" 'do-ungrey
|
||||
}dict $enddef
|
||||
|
||||
: main ( str -- )
|
||||
dup STRparse ( str strX strY strZ )
|
||||
3 pick string? if 3 pick "#" stringpfx if ( str strX strY strZ )
|
||||
pop pop pop ( str )
|
||||
"#" split strcat ( str' )
|
||||
do-say exit ( )
|
||||
then then
|
||||
3 pick int? if pop pop pop do-say exit then
|
||||
4 rotate pop ( strX strY strZ )
|
||||
|
||||
rot dict_commands over array_getitem ( strY strZ strX ? )
|
||||
dup address? if ( strY strZ strX adr )
|
||||
swap pop ( strY strZ adr )
|
||||
execute ( )
|
||||
else pop ( strY strZ strX )
|
||||
"I don't recognize the command '#%s'. Try 'say #help' for help, or using '##' to say something starting with '#'." fmtstring .tellbad ( strY strZ )
|
||||
pop pop ( )
|
||||
then ( )
|
||||
;
|
||||
.
|
||||
c
|
||||
q
|
||||
|
||||
lsedit #257=_help
|
||||
.del 1 $
|
||||
say <message>
|
||||
."<message>
|
||||
say #[!]ignore <names>
|
||||
say #[!]third
|
||||
say #[!]grey
|
||||
say #[!]meow <names>
|
||||
|
||||
Speaks <message> to the room. Use #ignore <name> to not see <name>'s says, poses, and spoofs; use #meow <name> to see <name>'s says with all the words replaced with "meow." Use #third to see your own says in the third person (that is, "Puck says" instead of the normal "You say"). Use #grey to turn off color in others' says and poses.
|
||||
|
||||
Say supports a "split" say if you put two consecutive commas in your message. For example, if CobaltBlue typed '"Hello,,how are you?' everyone would see '"Hello," says CobaltBlue, "how are you?"' You can also specify an "ad-hoc" verb by putting a message with your name or '%N' between pairs of commas: '"Hello,,%N welcomes Weiran,,how are you?' would display '"Hello," CobaltBlue welcomes Weiran, "how are you?"'
|
||||
.format 10=78
|
||||
.format 8=78
|
||||
.end
|
||||
5
samples/Makefile/foo.o.d
Normal file
5
samples/Makefile/foo.o.d
Normal file
@@ -0,0 +1,5 @@
|
||||
bar/foo.o: \
|
||||
bar/foo.c \
|
||||
bar/baz.h
|
||||
|
||||
bar/baz.h:
|
||||
150
samples/Mathematica/Predicates.wl
Normal file
150
samples/Mathematica/Predicates.wl
Normal file
@@ -0,0 +1,150 @@
|
||||
(* ::Package:: *)
|
||||
|
||||
BeginPackage["Predicates`"];
|
||||
|
||||
|
||||
(* ::Title:: *)
|
||||
(*Predicates*)
|
||||
|
||||
|
||||
(* ::Section::Closed:: *)
|
||||
(*Fuzzy Logic*)
|
||||
|
||||
|
||||
(* ::Subsection:: *)
|
||||
(*Documentation*)
|
||||
|
||||
|
||||
PossiblyTrueQ::usage="Returns True if the argument is not definitely False.";
|
||||
PossiblyFalseQ::usage="Returns True if the argument is not definitely True.";
|
||||
PossiblyNonzeroQ::usage="Returns True if and only if its argument is not definitely zero.";
|
||||
|
||||
|
||||
(* ::Subsection:: *)
|
||||
(*Implimentation*)
|
||||
|
||||
|
||||
Begin["`Private`"];
|
||||
|
||||
|
||||
PossiblyTrueQ[expr_]:=\[Not]TrueQ[\[Not]expr]
|
||||
|
||||
|
||||
PossiblyFalseQ[expr_]:=\[Not]TrueQ[expr]
|
||||
|
||||
|
||||
End[];
|
||||
|
||||
|
||||
(* ::Section::Closed:: *)
|
||||
(*Numbers and Lists*)
|
||||
|
||||
|
||||
(* ::Subsection:: *)
|
||||
(*Documentation*)
|
||||
|
||||
|
||||
AnyQ::usage="Given a predicate and a list, retuns True if and only if that predicate is True for at least one element of the list.";
|
||||
AnyElementQ::usage="Returns True if cond matches any element of L.";
|
||||
AllQ::usage="Given a predicate and a list, retuns True if and only if that predicate is True for all elements of the list.";
|
||||
AllElementQ::usage="Returns True if cond matches any element of L.";
|
||||
|
||||
|
||||
AnyNonzeroQ::usage="Returns True if L is a list such that at least one element is definitely not zero.";
|
||||
AnyPossiblyNonzeroQ::usage="Returns True if expr is a list such that at least one element is not definitely zero.";
|
||||
|
||||
|
||||
RealQ::usage="Returns True if and only if the argument is a real number";
|
||||
PositiveQ::usage="Returns True if and only if the argument is a positive real number";
|
||||
NonnegativeQ::usage="Returns True if and only if the argument is a non-negative real number";
|
||||
PositiveIntegerQ::usage="Returns True if and only if the argument is a positive integer";
|
||||
NonnegativeIntegerQ::usage="Returns True if and only if the argument is a non-negative integer";
|
||||
|
||||
|
||||
IntegerListQ::usage="Returns True if and only if the input is a list of integers.";
|
||||
PositiveIntegerListQ::usage="Returns True if and only if the input is a list of positive integers.";
|
||||
NonnegativeIntegerListQ::usage="Returns True if and only if the input is a list of non-negative integers.";
|
||||
IntegerOrListQ::usage="Returns True if and only if the input is a list of integers or an integer.";
|
||||
PositiveIntegerOrListQ::usage="Returns True if and only if the input is a list of positive integers or a positive integer.";
|
||||
NonnegativeIntegerOrListQ::usage="Returns True if and only if the input is a list of positive integers or a positive integer.";
|
||||
|
||||
|
||||
SymbolQ::usage="Returns True if argument is an unassigned symbol.";
|
||||
SymbolOrNumberQ::usage="Returns True if argument is a number of has head 'Symbol'";
|
||||
|
||||
|
||||
(* ::Subsection:: *)
|
||||
(*Implimentation*)
|
||||
|
||||
|
||||
Begin["`Private`"];
|
||||
|
||||
|
||||
AnyQ[cond_, L_] := Fold[Or, False, cond /@ L]
|
||||
|
||||
|
||||
AnyElementQ[cond_,L_]:=AnyQ[cond,Flatten[L]]
|
||||
|
||||
|
||||
AllQ[cond_, L_] := Fold[And, True, cond /@ L]
|
||||
|
||||
|
||||
AllElementQ[cond_, L_] := Fold[And, True, cond /@ L]
|
||||
|
||||
|
||||
AnyNonzeroQ[L_]:=AnyElementQ[#!=0&,L]
|
||||
|
||||
|
||||
PossiblyNonzeroQ[expr_]:=PossiblyTrueQ[expr!=0]
|
||||
|
||||
|
||||
AnyPossiblyNonzeroQ[expr_]:=AnyElementQ[PossiblyNonzeroQ,expr]
|
||||
|
||||
|
||||
RealQ[n_]:=TrueQ[Im[n]==0];
|
||||
|
||||
|
||||
PositiveQ[n_]:=Positive[n];
|
||||
|
||||
|
||||
PositiveIntegerQ[n_]:=PositiveQ[n]\[And]IntegerQ[n];
|
||||
|
||||
|
||||
NonnegativeQ[n_]:=TrueQ[RealQ[n]&&n>=0];
|
||||
|
||||
|
||||
NonnegativeIntegerQ[n_]:=NonnegativeQ[n]\[And]IntegerQ[n];
|
||||
|
||||
|
||||
IntegerListQ[input_]:=ListQ[input]&&Not[MemberQ[IntegerQ/@input,False]];
|
||||
|
||||
|
||||
IntegerOrListQ[input_]:=IntegerListQ[input]||IntegerQ[input];
|
||||
|
||||
|
||||
PositiveIntegerListQ[input_]:=IntegerListQ[input]&&Not[MemberQ[Positive[input],False]];
|
||||
|
||||
|
||||
PositiveIntegerOrListQ[input_]:=PositiveIntegerListQ[input]||PositiveIntegerQ[input];
|
||||
|
||||
|
||||
NonnegativeIntegerListQ[input_]:=IntegerListQ[input]&&Not[MemberQ[NonnegativeIntegerQ[input],False]];
|
||||
|
||||
|
||||
NonnegativeIntegerOrListQ[input_]:=NonnegativeIntegerListQ[input]||NonnegativeIntegerQ[input];
|
||||
|
||||
|
||||
SymbolQ[a_]:=Head[a]===Symbol;
|
||||
|
||||
|
||||
SymbolOrNumberQ[a_]:=NumericQ[a]||Head[a]===Symbol;
|
||||
|
||||
|
||||
End[];
|
||||
|
||||
|
||||
(* ::Section:: *)
|
||||
(*Epilogue*)
|
||||
|
||||
|
||||
EndPackage[];
|
||||
17
samples/Mathematica/UnitTest.wlt
Normal file
17
samples/Mathematica/UnitTest.wlt
Normal file
@@ -0,0 +1,17 @@
|
||||
BeginTestSection["Untitled-5"]
|
||||
|
||||
VerificationTest[(* 1 *)
|
||||
RotationMatrix[phi]
|
||||
,
|
||||
List[List[Cos[phi], Times[-1, Sin[phi]]], List[Sin[phi], Cos[phi]]]
|
||||
]
|
||||
|
||||
VerificationTest[(* 2 *)
|
||||
Times[1, Power[Plus[a, Times[-1, a]], -1]]
|
||||
,
|
||||
ComplexInfinity
|
||||
,
|
||||
{Power::infy}
|
||||
]
|
||||
|
||||
EndTestSection[]
|
||||
84
samples/NL/assign0.nl
Normal file
84
samples/NL/assign0.nl
Normal file
@@ -0,0 +1,84 @@
|
||||
g3 0 1 0 # problem assign0
|
||||
9 6 1 0 6 # vars, constraints, objectives, ranges, eqns
|
||||
0 0 # nonlinear constraints, objectives
|
||||
0 0 # network constraints: nonlinear, linear
|
||||
0 0 0 # nonlinear vars in constraints, objectives, both
|
||||
0 0 0 1 # linear network variables; functions; arith, flags
|
||||
9 0 0 0 0 # discrete variables: binary, integer, nonlinear (b,c,o)
|
||||
18 9 # nonzeros in Jacobian, gradients
|
||||
0 0 # max name lengths: constraints, variables
|
||||
0 0 0 0 0 # common exprs: b,c,o,c1,o1
|
||||
C0
|
||||
n0
|
||||
C1
|
||||
n0
|
||||
C2
|
||||
n0
|
||||
C3
|
||||
n0
|
||||
C4
|
||||
n0
|
||||
C5
|
||||
n0
|
||||
O0 0
|
||||
n0
|
||||
r
|
||||
4 1
|
||||
4 1
|
||||
4 1
|
||||
4 1
|
||||
4 1
|
||||
4 1
|
||||
b
|
||||
0 0 1
|
||||
0 0 1
|
||||
0 0 1
|
||||
0 0 1
|
||||
0 0 1
|
||||
0 0 1
|
||||
0 0 1
|
||||
0 0 1
|
||||
0 0 1
|
||||
k8
|
||||
2
|
||||
4
|
||||
6
|
||||
8
|
||||
10
|
||||
12
|
||||
14
|
||||
16
|
||||
J0 3
|
||||
0 1
|
||||
1 1
|
||||
2 1
|
||||
J1 3
|
||||
3 1
|
||||
4 1
|
||||
5 1
|
||||
J2 3
|
||||
6 1
|
||||
7 1
|
||||
8 1
|
||||
J3 3
|
||||
0 1
|
||||
3 1
|
||||
6 1
|
||||
J4 3
|
||||
1 1
|
||||
4 1
|
||||
7 1
|
||||
J5 3
|
||||
2 1
|
||||
5 1
|
||||
8 1
|
||||
G0 9
|
||||
0 1
|
||||
1 3
|
||||
2 3
|
||||
3 2
|
||||
4 3
|
||||
5 3
|
||||
6 3
|
||||
7 3
|
||||
8 2
|
||||
2284
samples/NL/balassign0.nl
Normal file
2284
samples/NL/balassign0.nl
Normal file
File diff suppressed because it is too large
Load Diff
49
samples/NewLisp/queens.nl
Normal file
49
samples/NewLisp/queens.nl
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env newlisp
|
||||
|
||||
(constant 'NUM 8)
|
||||
|
||||
(define (intersects? q1 q2)
|
||||
(or
|
||||
(= (q1 0) (q2 0))
|
||||
(= (q1 1) (q2 1))
|
||||
(= (abs (- (q1 0) (q2 0))) (abs (- (q1 1) (q2 1))))))
|
||||
|
||||
(define (variant? alist)
|
||||
(set 'logic nil)
|
||||
(cond
|
||||
((= (length alist) 1) true)
|
||||
((> (length alist) 1)
|
||||
(while (> (length alist) 1)
|
||||
(set 'q (pop alist -1))
|
||||
(dolist (el alist)
|
||||
(push
|
||||
(intersects?
|
||||
(list q (inc (length alist)))
|
||||
(list el (+ 1 $idx)))
|
||||
logic -1)))
|
||||
(not (apply or logic)))))
|
||||
|
||||
(define (fork-by-line alist)
|
||||
(let (res '())
|
||||
(dolist (i (sequence 1 NUM))
|
||||
(set 'tmp alist)
|
||||
(push i tmp -1)
|
||||
(setf res (push tmp res -1)))
|
||||
res))
|
||||
|
||||
(define (find-variants num)
|
||||
(let (res '())
|
||||
(cond
|
||||
((< num 1)
|
||||
(begin (println "num < 1") (exit)))
|
||||
((= num 1)
|
||||
(dolist (i (sequence 1 NUM)) (push (list i) res -1)))
|
||||
((> num 1)
|
||||
(dolist (v (find-variants (dec num)))
|
||||
(set 'passed (filter variant? (fork-by-line v)))
|
||||
(if (not (empty? passed)) (extend res passed)))))
|
||||
res))
|
||||
|
||||
(set 'solutions (find-variants NUM))
|
||||
(println (length solutions))
|
||||
;;(exit)
|
||||
15
samples/PLSQL/myobject.sql
Normal file
15
samples/PLSQL/myobject.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
create or replace type myobject
|
||||
AUTHID DEFINER
|
||||
AS OBJECT
|
||||
(
|
||||
m_name varchar2(200),
|
||||
member function toString RETURN VARCHAR2,
|
||||
map member function Compare return varchar2
|
||||
|
||||
)
|
||||
not instantiable not final;
|
||||
/
|
||||
|
||||
prompt create type myarray
|
||||
create or replace type myarray as table of myobject;
|
||||
/
|
||||
58
samples/PLSQL/packagebody.pkb
Normal file
58
samples/PLSQL/packagebody.pkb
Normal file
@@ -0,0 +1,58 @@
|
||||
CREATE OR REPLACE PACKAGE BODY linguistpackage
|
||||
AS
|
||||
/*
|
||||
* Package: linguist pacakage body
|
||||
* Purpose: a sample PLSQL file for linguist to work with
|
||||
*
|
||||
* Date: 03/03/2014
|
||||
* Author: david pyke le brun
|
||||
* Comments: initial version
|
||||
*/
|
||||
|
||||
PROCEDURE proc_1
|
||||
IS
|
||||
BEGIN
|
||||
NULL;
|
||||
END;
|
||||
|
||||
-- functions with 1 arg
|
||||
FUNCTION function1( param1 VARCHAR2 ) RETURN VARCHAR2
|
||||
IS
|
||||
CURSOR c IS
|
||||
select * from dual;
|
||||
v c%ROWTYPE;
|
||||
BEGIN
|
||||
open c;
|
||||
fetch c into v;
|
||||
close c;
|
||||
|
||||
return v;
|
||||
end;
|
||||
|
||||
FUNCTION function2( param1 NUMBER ) RETURN DATE
|
||||
IS
|
||||
BEGIN
|
||||
return SYSDATE;
|
||||
end;
|
||||
|
||||
--a few more to use all basic SQL types
|
||||
FUNCTION function3( param1 TIMESTAMP ) RETURN CHAR
|
||||
IS
|
||||
BEGIN
|
||||
IF 1 = 2 THEN
|
||||
return 'Y';
|
||||
ELSE
|
||||
return 'N';
|
||||
END IF;
|
||||
return NULL;
|
||||
END;
|
||||
|
||||
|
||||
FUNCTION function4( param1 CLOB ) RETURN BLOB
|
||||
IS
|
||||
BEGIN
|
||||
return null;
|
||||
END;
|
||||
|
||||
END linguistpackage;
|
||||
/
|
||||
28
samples/PLSQL/packageheader.pks
Normal file
28
samples/PLSQL/packageheader.pks
Normal file
@@ -0,0 +1,28 @@
|
||||
CREATE OR REPLACE PACKAGE linguistpackage
|
||||
AUTHID DEFINER
|
||||
AS
|
||||
/*
|
||||
* Package: linguist pacakage
|
||||
* Purpose: a sample PLSQL file for linguist to work with
|
||||
*
|
||||
* Date: 03/03/2014
|
||||
* Author: david pyke le brun
|
||||
* Comments: initial version
|
||||
*/
|
||||
|
||||
k_constant CONSTANT NUMBER(10,2) := 3.14;
|
||||
|
||||
--basic procedure
|
||||
PROCEDURE proc_1;
|
||||
|
||||
-- functions with 1 arg
|
||||
FUNCTION function1( param1 VARCHAR2 ) RETURN VARCHAR2;
|
||||
FUNCTION function2( param1 NUMBER ) RETURN DATE;
|
||||
|
||||
--a few more to use all basic SQL types
|
||||
FUNCTION function3( param1 TIMESTAMP ) RETURN CHAR;
|
||||
FUNCTION function4( param1 CLOB ) RETURN BLOB;
|
||||
|
||||
END linguistpackage;
|
||||
/
|
||||
|
||||
65
samples/PLSQL/who_called_me.sql
Normal file
65
samples/PLSQL/who_called_me.sql
Normal file
@@ -0,0 +1,65 @@
|
||||
CREATE OR REPLACE PROCEDURE who_called_me
|
||||
( owner OUT VARCHAR2,
|
||||
name OUT VARCHAR2,
|
||||
lineno OUT NUMBER,
|
||||
caller_t OUT VARCHAR2 ,
|
||||
depth NUMBER DEFAULT 1
|
||||
)
|
||||
AUTHID DEFINER
|
||||
AS
|
||||
--depth based version of who_called_me from asktom
|
||||
call_stack VARCHAR2(4096) default dbms_utility.format_call_stack;
|
||||
n NUMBER;
|
||||
found_stack BOOLEAN DEFAULT FALSE;
|
||||
line VARCHAR2(255);
|
||||
cnt NUMBER := 0;
|
||||
BEGIN
|
||||
LOOP
|
||||
n := instr( call_stack, chr(10) );
|
||||
exit when ( n is NULL or n = 0 );
|
||||
--
|
||||
line := substr( call_stack, 1, n-1 );
|
||||
call_stack := substr( call_stack, n+1 );
|
||||
--
|
||||
if ( NOT found_stack ) then
|
||||
if ( line like '%handle%number%name%' ) then
|
||||
found_stack := TRUE;
|
||||
end if;
|
||||
else
|
||||
cnt := cnt + 1;
|
||||
-- cnt = 1 is ME
|
||||
-- cnt = 2 is MY Caller
|
||||
-- cnt = 3 is Their Caller
|
||||
if ( cnt = (2+depth) ) then
|
||||
lineno := to_number(substr( line, 13, 8 ));
|
||||
line := substr( line, 23 ); --set to rest of line .. change from 21 to 23
|
||||
if ( line like 'pr%' ) then
|
||||
n := length( 'procedure ' );
|
||||
elsif ( line like 'fun%' ) then
|
||||
n := length( 'function ' );
|
||||
elsif ( line like 'package body%' ) then
|
||||
n := length( 'package body ' );
|
||||
elsif ( line like 'pack%' ) then
|
||||
n := length( 'package ' );
|
||||
elsif ( line like 'anonymous%' ) then
|
||||
n := length( 'anonymous block ' );
|
||||
else
|
||||
n := null;
|
||||
end if;
|
||||
if ( n is not null ) then
|
||||
caller_t := ltrim(rtrim(upper(substr( line, 1, n-1 ))));
|
||||
else
|
||||
caller_t := 'TRIGGER';
|
||||
end if;
|
||||
|
||||
line := substr( line, nvl(n,1) );
|
||||
n := instr( line, '.' );
|
||||
owner := ltrim(rtrim(substr( line, 1, n-1 )));
|
||||
name := LTRIM(RTRIM(SUBSTR( LINE, N+1 )));
|
||||
exit;
|
||||
END IF;
|
||||
END IF;
|
||||
END LOOP;
|
||||
END;
|
||||
/
|
||||
|
||||
165
samples/PLpgSQL/plpgsql_lint-8.4.sql
Normal file
165
samples/PLpgSQL/plpgsql_lint-8.4.sql
Normal file
@@ -0,0 +1,165 @@
|
||||
load 'plpgsql';
|
||||
load 'plpgsql_lint';
|
||||
|
||||
create table t1(a int, b int);
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
update t1 set c = 30;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
as $$
|
||||
select 10,20;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
r := g1();
|
||||
if false then
|
||||
raise notice '%', r.c;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
returns setof record as $$
|
||||
select * from t1;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
raise notice '%', r.c;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
r.c := 20;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function f1()
|
||||
returns int as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r := a + b;
|
||||
end if;
|
||||
return r;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '%', 1, 2;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '% %';
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int[];
|
||||
begin
|
||||
if false then
|
||||
r[c+10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r[10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create type diagnostic_info_type as (
|
||||
status text,
|
||||
message text,
|
||||
detail text,
|
||||
row_count int);
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare
|
||||
dg record;
|
||||
begin
|
||||
dg := NULL::diagnostic_info_type;
|
||||
if false then
|
||||
dg.status := '00000';
|
||||
dg.mistake := 'hello';
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
165
samples/PLpgSQL/plpgsql_lint-9.0.sql
Normal file
165
samples/PLpgSQL/plpgsql_lint-9.0.sql
Normal file
@@ -0,0 +1,165 @@
|
||||
load 'plpgsql';
|
||||
load 'plpgsql_lint';
|
||||
|
||||
create table t1(a int, b int);
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
update t1 set c = 30;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
as $$
|
||||
select 10,20;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
r := g1();
|
||||
if false then
|
||||
raise notice '%', r.c;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
returns setof record as $$
|
||||
select * from t1;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
raise notice '%', r.c;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
r.c := 20;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function f1()
|
||||
returns int as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r := a + b;
|
||||
end if;
|
||||
return r;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '%', 1, 2;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '% %';
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int[];
|
||||
begin
|
||||
if false then
|
||||
r[c+10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r[10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create type diagnostic_info_type as (
|
||||
status text,
|
||||
message text,
|
||||
detail text,
|
||||
row_count int);
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare
|
||||
dg record;
|
||||
begin
|
||||
dg := NULL::diagnostic_info_type;
|
||||
if false then
|
||||
dg.status := '00000';
|
||||
dg.mistake := 'hello';
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
179
samples/PLpgSQL/plpgsql_lint-9.1.sql
Normal file
179
samples/PLpgSQL/plpgsql_lint-9.1.sql
Normal file
@@ -0,0 +1,179 @@
|
||||
load 'plpgsql';
|
||||
load 'plpgsql_lint';
|
||||
|
||||
create table t1(a int, b int);
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
update t1 set c = 30;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
as $$
|
||||
select 10,20;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
r := g1();
|
||||
if false then
|
||||
raise notice '%', r.c;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
returns setof record as $$
|
||||
select * from t1;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
raise notice '%', r.c;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
r.c := 20;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function f1()
|
||||
returns int as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r := a + b;
|
||||
end if;
|
||||
return r;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '%', 1, 2;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '% %';
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int[];
|
||||
begin
|
||||
if false then
|
||||
r[c+10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r[10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create type diagnostic_info_type as (
|
||||
status text,
|
||||
message text,
|
||||
detail text,
|
||||
row_count int);
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare dg record;
|
||||
begin
|
||||
dg := NULL::diagnostic_info_type;
|
||||
if false then
|
||||
dg.status := '00000';
|
||||
dg.mistake := 'hello';
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare dg record;
|
||||
begin
|
||||
if false then
|
||||
dg := 10,20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
166
samples/PLpgSQL/plpgsql_lint-9.2.sql
Normal file
166
samples/PLpgSQL/plpgsql_lint-9.2.sql
Normal file
@@ -0,0 +1,166 @@
|
||||
load 'plpgsql';
|
||||
load 'plpgsql_lint';
|
||||
|
||||
create table t1(a int, b int);
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
update t1 set c = 30;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
as $$
|
||||
select 10,20;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
r := g1();
|
||||
if false then
|
||||
raise notice '%', r.c;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
returns setof record as $$
|
||||
select * from t1;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
raise notice '%', r.c;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
r.c := 20;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function f1()
|
||||
returns int as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r := a + b;
|
||||
end if;
|
||||
return r;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '%', 1, 2;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '% %';
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int[];
|
||||
begin
|
||||
if false then
|
||||
r[c+10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r[10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create type _exception_type as (
|
||||
state text,
|
||||
message text,
|
||||
detail text);
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare
|
||||
_exception record;
|
||||
begin
|
||||
_exception := NULL::_exception_type;
|
||||
exception when others then
|
||||
get stacked diagnostics
|
||||
_exception.state = RETURNED_SQLSTATE,
|
||||
_exception.message = MESSAGE_TEXT,
|
||||
_exception.detail = PG_EXCEPTION_DETAIL,
|
||||
_exception.hint = PG_EXCEPTION_HINT;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
166
samples/PLpgSQL/plpgsql_lint-9.3.sql
Normal file
166
samples/PLpgSQL/plpgsql_lint-9.3.sql
Normal file
@@ -0,0 +1,166 @@
|
||||
load 'plpgsql';
|
||||
load 'plpgsql_lint';
|
||||
|
||||
create table t1(a int, b int);
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
update t1 set c = 30;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
as $$
|
||||
select 10,20;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
r := g1();
|
||||
if false then
|
||||
raise notice '%', r.c;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function g1(out a int, out b int)
|
||||
returns setof record as $$
|
||||
select * from t1;
|
||||
$$ language sql;
|
||||
|
||||
create function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
raise notice '%', r.c;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r record;
|
||||
begin
|
||||
for r in select * from g1()
|
||||
loop
|
||||
r.c := 20;
|
||||
end loop;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
drop function g1();
|
||||
|
||||
create function f1()
|
||||
returns int as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r := a + b;
|
||||
end if;
|
||||
return r;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '%', 1, 2;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
begin
|
||||
if false then
|
||||
raise notice '% %';
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int[];
|
||||
begin
|
||||
if false then
|
||||
r[c+10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare r int;
|
||||
begin
|
||||
if false then
|
||||
r[10] := 20;
|
||||
end if;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
|
||||
create type _exception_type as (
|
||||
state text,
|
||||
message text,
|
||||
detail text);
|
||||
|
||||
create or replace function f1()
|
||||
returns void as $$
|
||||
declare
|
||||
_exception record;
|
||||
begin
|
||||
_exception := NULL::_exception_type;
|
||||
exception when others then
|
||||
get stacked diagnostics
|
||||
_exception.state = RETURNED_SQLSTATE,
|
||||
_exception.message = MESSAGE_TEXT,
|
||||
_exception.detail = PG_EXCEPTION_DETAIL,
|
||||
_exception.hint = PG_EXCEPTION_HINT;
|
||||
end;
|
||||
$$ language plpgsql;
|
||||
|
||||
select f1();
|
||||
|
||||
drop function f1();
|
||||
117
samples/Perl/exception_handler.pl
Normal file
117
samples/Perl/exception_handler.pl
Normal file
@@ -0,0 +1,117 @@
|
||||
package exception_handler;
|
||||
use sigtrap qw(die normal-signals);
|
||||
use IO::Handle;
|
||||
use Carp;
|
||||
use File::Spec;
|
||||
use File::Basename;
|
||||
use Data::Dumper;
|
||||
|
||||
use sigtrap 'handler', \&tm_die;
|
||||
|
||||
$Carp::CarpLevel = 1; # How many extra package levels to skip on carp.
|
||||
|
||||
BEGIN {
|
||||
*CORE::GLOBAL::die = \&tm_die;
|
||||
$main::SIG{__DIE__} = \&tm_die;
|
||||
my $error_fd = $ENV{"TM_ERROR_FD"};
|
||||
open (TM_ERROR_FD, ">&=$error_fd");
|
||||
TM_ERROR_FD->autoflush(1);
|
||||
}
|
||||
|
||||
sub realwarn { CORE::warn(@_); }
|
||||
sub realdie { CORE::die(@_); }
|
||||
|
||||
sub longmess {
|
||||
my ($arg, @rest) = shift;
|
||||
{
|
||||
local $@;
|
||||
# XXX fix require to not clear $@?
|
||||
# don't use require unless we need to (for Safe compartments)
|
||||
require Carp::Heavy unless $INC{"Carp/Heavy.pm"};
|
||||
}
|
||||
# Icky backwards compatibility wrapper. :-(
|
||||
my $call_pack = caller();
|
||||
if ($Internal{$call_pack} or $Carp::CarpInternal{$call_pack}) {
|
||||
return longmess_heavy($arg, @rest);
|
||||
}
|
||||
else {
|
||||
local $Carp::CarpLevel = $Carp::CarpLevel + 1;
|
||||
return longmess_heavy($arg, @rest);
|
||||
}
|
||||
}
|
||||
|
||||
sub longmess_heavy {
|
||||
return @_ if ref($_[0]); # don't break references as exceptions
|
||||
my $i = Carp::long_error_loc();
|
||||
my ($arg, @rest) = @_;
|
||||
return ret_backtrace($i, $arg, @rest);
|
||||
}
|
||||
|
||||
sub quote {
|
||||
my $str = shift;
|
||||
$str =~ s/([^A-Za-z0-9\/_.-])/sprintf("%%%02X", ord($1))/seg;
|
||||
return $str;
|
||||
}
|
||||
|
||||
sub url_and_display_name {
|
||||
my $file = shift;
|
||||
my $url = "";
|
||||
my $display_name = "";
|
||||
$display_name = basename($file);
|
||||
$url = 'url=file://' . quote($file);
|
||||
return ($url, $display_name);
|
||||
}
|
||||
|
||||
# Returns a full stack backtrace starting from where it is
|
||||
# told.
|
||||
sub ret_backtrace {
|
||||
my ($i, $arg, @rest) = @_;
|
||||
my $mess;
|
||||
$i++;
|
||||
|
||||
my $tid_msg = '';
|
||||
if (defined &Thread::tid) {
|
||||
my $tid = Thread->self->tid;
|
||||
$tid_msg = " thread $tid" if $tid;
|
||||
}
|
||||
|
||||
my %i = Carp::caller_info($i);
|
||||
$arg =~ s/\n/\<br\>/g;
|
||||
$i{sub} =~ s/tm_die/die/g;
|
||||
$mess .= "<div id='exception_report' class='framed'>\n";
|
||||
$mess .= "<p id='exception'><strong>$arg</strong></p>\n";
|
||||
$mess .= "<blockquote><table border='0' cellspacing='0' cellpadding='0'>\n";
|
||||
my ($url, $display_name) = url_and_display_name($i{file});
|
||||
$mess .= "<tr><td><a href='txmt://open?line=$i{line}&" . $url . "'>$i{sub}</a></td><td> in $display_name at line $i{line}$tid_msg</td></tr>\n";
|
||||
while (my %i = Carp::caller_info(++$i)) {
|
||||
($url, $display_name) = url_and_display_name($i{file});
|
||||
$mess .= "<tr><td><a href='txmt://open?line=$i{line}&" . $url . "'>$i{sub}</a></td><td> in $display_name at line $i{line}$tid_msg</td></tr>\n";
|
||||
}
|
||||
$mess .= "</table></blockquote></div>";
|
||||
return $mess;
|
||||
}
|
||||
|
||||
sub ineval {
|
||||
(exists $ENV{MOD_PERL} ? 0 : $^S) || Carp::longmess() =~ /eval [\{\']/m
|
||||
}
|
||||
|
||||
sub htmlize {
|
||||
my $l = shift;
|
||||
$l =~ s/&/&/g;
|
||||
$l =~ s/</</g;
|
||||
$l =~ s/>/>/g;
|
||||
return $l;
|
||||
}
|
||||
|
||||
sub tm_die {
|
||||
my ($arg,@rest) = @_;
|
||||
if (ineval()) {
|
||||
realdie ($arg,@rest) if ineval();
|
||||
}
|
||||
if (!ref($arg)) {
|
||||
print TM_ERROR_FD longmess($arg,@rest);
|
||||
}
|
||||
exit($!);
|
||||
}
|
||||
|
||||
1;
|
||||
4
samples/Ruby/index.json.jbuilder
Normal file
4
samples/Ruby/index.json.jbuilder
Normal file
@@ -0,0 +1,4 @@
|
||||
json.array!(@courts) do |court|
|
||||
json.extract! court, :id, :name_r, :region, :region_r, :email, :website
|
||||
json.url court_url(court, format: :json)
|
||||
end
|
||||
21
samples/SQL/create_stuff.sql
Normal file
21
samples/SQL/create_stuff.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
CREATE TABLE x AS SELECT * FROM DUAL;
|
||||
|
||||
CREATE TABLE y (
|
||||
col1 NUMBER NOT NULL ,
|
||||
col2 VARCHAR2(200),
|
||||
col3 DATE,
|
||||
col4 TIMESTAMP WITH TIME ZONE NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE USER username IDENTIFIED BY password;
|
||||
|
||||
GRANT CONNECT, RESOURCE TO username;
|
||||
|
||||
|
||||
GRANT CREATE TYPE TO username;
|
||||
GRANT CREATE PROCEDURE TO username;
|
||||
GRANT CREATE TABLE TO username;
|
||||
GRANT CREATE VIEW TO username;
|
||||
|
||||
13
samples/SQL/drop_stuff.sql
Normal file
13
samples/SQL/drop_stuff.sql
Normal file
@@ -0,0 +1,13 @@
|
||||
drop procedure who_called_me;
|
||||
drop package body linguist_package;
|
||||
drop package linguist_package;
|
||||
drop function functionname1;
|
||||
|
||||
drop table x;
|
||||
drop table y cascade;
|
||||
|
||||
drop type typename1;
|
||||
drop type typename2;
|
||||
|
||||
drop view viewname1;
|
||||
drop view viewname2;
|
||||
3
samples/SQL/dual.sql
Normal file
3
samples/SQL/dual.sql
Normal file
@@ -0,0 +1,3 @@
|
||||
--this is the most basic oracle sql command
|
||||
select * from dual;
|
||||
|
||||
39
samples/SQLPL/check_reorg.sql
Normal file
39
samples/SQLPL/check_reorg.sql
Normal file
@@ -0,0 +1,39 @@
|
||||
create procedure check_reorg_tables (in v_schema varchar(128), out v_reorg_counter integer)
|
||||
begin
|
||||
|
||||
declare loc result_set_locator varying;
|
||||
|
||||
declare schema_out varchar(128);
|
||||
declare table_out varchar(128);
|
||||
declare card_out integer;
|
||||
declare overflow_out integer;
|
||||
declare npages_out integer;
|
||||
declare fpages_out integer;
|
||||
declare active_blocks_out integer;
|
||||
declare tsize_out integer;
|
||||
declare f1_out integer;
|
||||
declare f2_out integer;
|
||||
declare f3_out integer;
|
||||
declare reorg_out varchar(3);
|
||||
declare cursor_end smallint default 0;
|
||||
|
||||
declare continue handler for NOT FOUND
|
||||
|
||||
set cursor_end = 1;
|
||||
set v_reorg_counter = 0;
|
||||
|
||||
call reorgchk_tb_stats('S', v_schema);
|
||||
associate result set locator(loc) with procedure reorgchk_tb_stats;
|
||||
allocate mycursor cursor for result set loc;
|
||||
|
||||
open mycursor;
|
||||
repeat
|
||||
fetch from mycursor into schema_out, table_out, card_out, overflow_out, npages_out, fpages_out, active_blocks_out, tsize_out, f1_out, f2_out, f3_out, reorg_out;
|
||||
if reorg_out <> '---' then
|
||||
set v_reorg_counter = v_reorg_counter + 1;
|
||||
end if;
|
||||
until cursor_end = 1
|
||||
end repeat;
|
||||
close mycursor;
|
||||
|
||||
end!
|
||||
30
samples/SQLPL/comm_amount.db2
Normal file
30
samples/SQLPL/comm_amount.db2
Normal file
@@ -0,0 +1,30 @@
|
||||
DROP FUNCTION COMM_AMOUNT;
|
||||
CREATE FUNCTION COMM_AMOUNT(SALARY DEC(9,2))
|
||||
RETURNS DEC(9,2)
|
||||
LANGUAGE SQL READS SQL DATA
|
||||
BEGIN ATOMIC
|
||||
DECLARE REMAINDER DEC(9,2) DEFAULT 0.0;--
|
||||
DECLARE COMM_PAID DEC(9,2) DEFAULT 0.0;--
|
||||
DECLARE COMM_INCR INT DEFAULT 1;--
|
||||
DECLARE MAX_COMM DEC(9,2) DEFAULT 0.0;--
|
||||
|
||||
IF (SALARY <= 0) THEN
|
||||
SIGNAL SQLSTATE '75000'
|
||||
SET MESSAGE_TEXT = 'Bad Salary';--
|
||||
END IF;--
|
||||
|
||||
SET REMAINDER = SALARY;--
|
||||
|
||||
L1: WHILE REMAINDER > 0.0 DO
|
||||
SET COMM_PAID = COMM_PAID + (COMM_INCR * 500.00);--
|
||||
SET REMAINDER = REMAINDER-(COMM_INCR * 5000.00);--
|
||||
SET COMM_INCR = COMM_INCR + 1;--
|
||||
END WHILE L1;--
|
||||
|
||||
SET MAX_COMM =
|
||||
(SELECT SUM(SALARY)/100.00 FROM EMPLOYEE);--
|
||||
IF (COMM_PAID > MAX_COMM) THEN
|
||||
SET COMM_PAID = MAX_COMM;--
|
||||
END IF;--
|
||||
RETURN COMM_PAID;--
|
||||
END;
|
||||
13
samples/SQLPL/drop_table.db2
Normal file
13
samples/SQLPL/drop_table.db2
Normal file
@@ -0,0 +1,13 @@
|
||||
DROP TABLE TDEPT;
|
||||
CREATE TABLE TDEPT (DEPTNO CHAR(4));
|
||||
|
||||
--#SET TERMINATOR @
|
||||
BEGIN ATOMIC
|
||||
DECLARE COUNT INT DEFAULT 5;
|
||||
|
||||
WHILE COUNT > 0 DO
|
||||
INSERT INTO TDEPT VALUES 'F'||
|
||||
RTRIM(CHAR(COUNT));
|
||||
SET COUNT = COUNT - 1;
|
||||
END WHILE;
|
||||
END@
|
||||
18
samples/SQLPL/runstats.sql
Normal file
18
samples/SQLPL/runstats.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
create procedure runstats (out nr_tables integer, out nr_ok integer)
|
||||
begin
|
||||
declare SQLCODE integer;
|
||||
declare stmt varchar(100);
|
||||
|
||||
set nr_tables = 0;
|
||||
set nr_ok = 0;
|
||||
|
||||
for line as select tabschema, tabname from syscat.tables where type='T' and tabschema='SPODEN'
|
||||
do
|
||||
set nr_tables = nr_tables + 1;
|
||||
set stmt = 'CALL SYSPROC.ADMIN_CMD (RUNSTATS ON TABLE ' concat rtrim(line.tabschema) concat '.' concat line.tabname concat ')';
|
||||
execute immediate stmt;
|
||||
if SQLCODE = 0 then
|
||||
set nr_ok = nr_ok + 1;
|
||||
end if;
|
||||
end for;
|
||||
end!
|
||||
9
samples/SQLPL/sleep.sql
Normal file
9
samples/SQLPL/sleep.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
create procedure sleep (in sleeptime integer)
|
||||
begin
|
||||
declare wait_until timestamp;
|
||||
|
||||
set wait_until = (current timestamp + sleeptime seconds);
|
||||
while (wait_until > current timestamp)
|
||||
do
|
||||
end while;
|
||||
end!
|
||||
9
samples/SQLPL/trigger.sql
Normal file
9
samples/SQLPL/trigger.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
create trigger CHECK_HIREDATE
|
||||
no cascade before insert on EMPLOYEE
|
||||
referencing new as N
|
||||
for each row mode db2sql
|
||||
if n.hiredate > current date
|
||||
then
|
||||
signal SQLSTATE '75000'
|
||||
set MESSAGE_TEXT = 'Hire date must be in the past';
|
||||
end if!
|
||||
272
samples/SourcePawn/foo.sma
Normal file
272
samples/SourcePawn/foo.sma
Normal file
@@ -0,0 +1,272 @@
|
||||
// vim: set ts=4 sw=4 tw=99 noet:
|
||||
//
|
||||
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
||||
// Copyright (C) The AMX Mod X Development Team.
|
||||
//
|
||||
// This software is licensed under the GNU General Public License, version 3 or higher.
|
||||
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
||||
// https://alliedmods.net/amxmodx-license
|
||||
|
||||
//
|
||||
// TimeLeft Plugin
|
||||
//
|
||||
|
||||
#include <amxmodx>
|
||||
|
||||
const TASK_TIMEREMAIN_SHORT = 8648458 // 0.8s repeat task
|
||||
const TASK_TIMEREMAIN_LARGE = 34543 // 1.0s repeat task
|
||||
|
||||
// time display flags
|
||||
const TD_BOTTOM_WHITE_TEXT = 1 // a - display white text on bottom
|
||||
const TD_USE_VOICE = 2 // b - use voice
|
||||
const TD_NO_REMAINING_VOICE = 4 // c - don't add "remaining" (only in voice)
|
||||
const TD_NO_HOURS_MINS_SECS_VOICE = 8 // d - don't add "hours/minutes/seconds" (only in voice)
|
||||
const TD_SHOW_SPEAK_VALUES_BELOW = 16 // e - show/speak if current time is less than this set in parameter
|
||||
|
||||
new g_TimeSet[32][2]
|
||||
new g_LastTime
|
||||
new g_CountDown
|
||||
new g_Switch
|
||||
|
||||
// pcvars
|
||||
new g_amx_time_voice, g_amx_timeleft
|
||||
new g_mp_timelimit
|
||||
|
||||
public plugin_init()
|
||||
{
|
||||
register_plugin("TimeLeft", AMXX_VERSION_STR, "AMXX Dev Team")
|
||||
register_dictionary("timeleft.txt")
|
||||
g_amx_time_voice = register_cvar("amx_time_voice", "1")
|
||||
register_srvcmd("amx_time_display", "setDisplaying")
|
||||
g_amx_timeleft = register_cvar("amx_timeleft", "00:00", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_UNLOGGED|FCVAR_SPONLY)
|
||||
register_clcmd("say timeleft", "sayTimeLeft", 0, "- displays timeleft")
|
||||
register_clcmd("say thetime", "sayTheTime", 0, "- displays current time")
|
||||
|
||||
set_task(0.8, "timeRemain", TASK_TIMEREMAIN_SHORT, "", 0, "b")
|
||||
|
||||
g_mp_timelimit = get_cvar_pointer("mp_timelimit")
|
||||
}
|
||||
|
||||
public sayTheTime(id)
|
||||
{
|
||||
if (get_pcvar_num(g_amx_time_voice))
|
||||
{
|
||||
new mhours[6], mmins[6], whours[32], wmins[32], wpm[6]
|
||||
|
||||
get_time("%H", mhours, charsmax(mhours))
|
||||
get_time("%M", mmins, charsmax(mmins))
|
||||
|
||||
new mins = str_to_num(mmins)
|
||||
new hrs = str_to_num(mhours)
|
||||
|
||||
if (mins)
|
||||
num_to_word(mins, wmins, charsmax(wmins))
|
||||
else
|
||||
wmins[0] = EOS
|
||||
|
||||
if (hrs < 12)
|
||||
wpm = "am "
|
||||
else
|
||||
{
|
||||
if (hrs > 12) hrs -= 12
|
||||
wpm = "pm "
|
||||
}
|
||||
|
||||
if (hrs)
|
||||
num_to_word(hrs, whours, charsmax(whours))
|
||||
else
|
||||
whours = "twelve "
|
||||
|
||||
client_cmd(id, "spk ^"fvox/time_is_now %s_period %s%s^"", whours, wmins, wpm)
|
||||
}
|
||||
|
||||
new ctime[64]
|
||||
|
||||
get_time("%m/%d/%Y - %H:%M:%S", ctime, charsmax(ctime))
|
||||
client_print(0, print_chat, "%L: %s", LANG_PLAYER, "THE_TIME", ctime)
|
||||
|
||||
return PLUGIN_CONTINUE
|
||||
}
|
||||
|
||||
public sayTimeLeft(id)
|
||||
{
|
||||
if (get_pcvar_float(g_mp_timelimit))
|
||||
{
|
||||
new a = get_timeleft()
|
||||
|
||||
if (get_pcvar_num(g_amx_time_voice))
|
||||
{
|
||||
new svoice[128]
|
||||
setTimeVoice(svoice, charsmax(svoice), 0, a)
|
||||
client_cmd(id, "%s", svoice)
|
||||
}
|
||||
client_print(0, print_chat, "%L: %d:%02d", LANG_PLAYER, "TIME_LEFT", (a / 60), (a % 60))
|
||||
}
|
||||
else
|
||||
client_print(0, print_chat, "%L", LANG_PLAYER, "NO_T_LIMIT")
|
||||
|
||||
return PLUGIN_CONTINUE
|
||||
}
|
||||
|
||||
setTimeText(text[], len, tmlf, id)
|
||||
{
|
||||
new secs = tmlf % 60
|
||||
new mins = tmlf / 60
|
||||
|
||||
if (secs == 0)
|
||||
formatex(text, len, "%d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE")
|
||||
else if (mins == 0)
|
||||
formatex(text, len, "%d %L", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
|
||||
else
|
||||
formatex(text, len, "%d %L %d %L", mins, id, (mins > 1) ? "MINUTES" : "MINUTE", secs, id, (secs > 1) ? "SECONDS" : "SECOND")
|
||||
}
|
||||
|
||||
setTimeVoice(text[], len, flags, tmlf)
|
||||
{
|
||||
new temp[7][32]
|
||||
new secs = tmlf % 60
|
||||
new mins = tmlf / 60
|
||||
|
||||
// for (new a = 0;a < 7;++a) // we just created it, already null
|
||||
// temp[a][0] = 0
|
||||
|
||||
if (secs > 0)
|
||||
{
|
||||
num_to_word(secs, temp[4], charsmax(temp[]))
|
||||
|
||||
if ( ~flags & TD_NO_HOURS_MINS_SECS_VOICE )
|
||||
temp[5] = "seconds " /* there is no "second" in default hl */
|
||||
}
|
||||
|
||||
if (mins > 59)
|
||||
{
|
||||
new hours = mins / 60
|
||||
|
||||
num_to_word(hours, temp[0], charsmax(temp[]))
|
||||
|
||||
if ( ~flags & TD_NO_HOURS_MINS_SECS_VOICE )
|
||||
temp[1] = "hours "
|
||||
|
||||
mins = mins % 60
|
||||
}
|
||||
|
||||
if (mins > 0)
|
||||
{
|
||||
num_to_word(mins, temp[2], charsmax(temp[]))
|
||||
|
||||
if ( ~flags & TD_NO_HOURS_MINS_SECS_VOICE )
|
||||
temp[3] = "minutes "
|
||||
}
|
||||
|
||||
if ( ~flags & TD_NO_REMAINING_VOICE )
|
||||
temp[6] = "remaining "
|
||||
|
||||
return formatex(text, len, "spk ^"vox/%s%s%s%s%s%s%s^"", temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6])
|
||||
}
|
||||
|
||||
findDispFormat(_time)
|
||||
{
|
||||
// it is important to check i<sizeof BEFORE g_TimeSet[i][0] to prevent out of bound error
|
||||
for (new i = 0; i < sizeof(g_TimeSet) && g_TimeSet[i][0]; ++i)
|
||||
{
|
||||
if (g_TimeSet[i][1] & TD_SHOW_SPEAK_VALUES_BELOW)
|
||||
{
|
||||
if (g_TimeSet[i][0] > _time)
|
||||
{
|
||||
if (!g_Switch)
|
||||
{
|
||||
g_CountDown = g_Switch = _time
|
||||
remove_task(TASK_TIMEREMAIN_SHORT)
|
||||
set_task(1.0, "timeRemain", TASK_TIMEREMAIN_LARGE, "", 0, "b")
|
||||
}
|
||||
|
||||
return i
|
||||
}
|
||||
}
|
||||
else if (g_TimeSet[i][0] == _time)
|
||||
{
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
public setDisplaying()
|
||||
{
|
||||
new arg[32], flags[32], num[32]
|
||||
new argc = read_argc() - 1
|
||||
new i = 0
|
||||
|
||||
while (i < argc && i < sizeof(g_TimeSet))
|
||||
{
|
||||
read_argv(i + 1, arg, charsmax(arg))
|
||||
parse(arg, flags, charsmax(flags), num, charsmax(num))
|
||||
|
||||
g_TimeSet[i][0] = str_to_num(num)
|
||||
g_TimeSet[i][1] = read_flags(flags)
|
||||
|
||||
i++
|
||||
}
|
||||
|
||||
if( i < sizeof(g_TimeSet) )
|
||||
g_TimeSet[i][0] = 0 // has to be zeroed in case command is sent twice
|
||||
|
||||
return PLUGIN_HANDLED
|
||||
}
|
||||
|
||||
public timeRemain(param[])
|
||||
{
|
||||
new gmtm = get_timeleft()
|
||||
new tmlf = g_Switch ? --g_CountDown : gmtm
|
||||
new stimel[12]
|
||||
|
||||
formatex(stimel, charsmax(stimel), "%02d:%02d", gmtm / 60, gmtm % 60)
|
||||
set_pcvar_string(g_amx_timeleft, stimel)
|
||||
|
||||
if (g_Switch && gmtm > g_Switch)
|
||||
{
|
||||
remove_task(TASK_TIMEREMAIN_LARGE)
|
||||
g_Switch = 0
|
||||
set_task(0.8, "timeRemain", TASK_TIMEREMAIN_SHORT, "", 0, "b")
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (tmlf > 0 && g_LastTime != tmlf)
|
||||
{
|
||||
g_LastTime = tmlf
|
||||
new tm_set = findDispFormat(tmlf)
|
||||
|
||||
if (tm_set != -1)
|
||||
{
|
||||
new flags = g_TimeSet[tm_set][1]
|
||||
new arg[128]
|
||||
|
||||
if (flags & TD_BOTTOM_WHITE_TEXT)
|
||||
{
|
||||
new players[MAX_PLAYERS], pnum, plr
|
||||
|
||||
get_players(players, pnum, "c")
|
||||
|
||||
if (flags & TD_SHOW_SPEAK_VALUES_BELOW) // yes this is correct flag, just because message should be shorter if it is shown every seconds
|
||||
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 1.1, 0.1, 0.5, -1)
|
||||
else
|
||||
set_hudmessage(255, 255, 255, -1.0, 0.85, 0, 0.0, 3.0, 0.0, 0.5, -1)
|
||||
|
||||
for (new i = 0; i < pnum; i++)
|
||||
{
|
||||
plr = players[i]
|
||||
setTimeText(arg, charsmax(arg), tmlf, plr)
|
||||
show_hudmessage(plr, "%s", arg)
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & TD_USE_VOICE)
|
||||
{
|
||||
setTimeVoice(arg, charsmax(arg), flags, tmlf)
|
||||
client_cmd(0, "%s", arg)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
466
samples/XS/CommonMark.xs
Normal file
466
samples/XS/CommonMark.xs
Normal file
@@ -0,0 +1,466 @@
|
||||
/*
|
||||
* This software is copyright (C) by Nick Wellnhofer <wellnhofer@aevum.de>.
|
||||
*
|
||||
* This is free software; you can redistribute it and/or modify it under
|
||||
* the same terms as the Perl 5 programming language system itself.
|
||||
*
|
||||
* Terms of the Perl programming language system itself
|
||||
*
|
||||
* a) the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 1, or (at your option) any
|
||||
* later version, or
|
||||
* b) the "Artistic License"
|
||||
*/
|
||||
|
||||
/*
|
||||
* Notes on memory management
|
||||
*
|
||||
* - A pointer to the Perl SV representing a node is stored in the
|
||||
* user data slot of `struct cmark_node`, so there's a 1:1 mapping
|
||||
* between Perl and C objects.
|
||||
* - Every node SV keeps a reference to the parent SV. This is done
|
||||
* indirectly by looking up the parent SV and increasing its refcount.
|
||||
* - This makes sure that a document isn't freed if the last reference
|
||||
* from Perl to the root node is dropped, as references to child nodes
|
||||
* might still exist.
|
||||
* - As a consequence, as long as a node is referenced from Perl, all its
|
||||
* ancestor nodes will also be associated with a Perl object.
|
||||
*/
|
||||
|
||||
#define PERL_NO_GET_CONTEXT
|
||||
|
||||
#include "EXTERN.h"
|
||||
#include "perl.h"
|
||||
#include "XSUB.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cmark.h>
|
||||
|
||||
#if CMARK_VERSION < 0x001000
|
||||
#error libcmark 0.16.0 is required.
|
||||
#endif
|
||||
|
||||
/* Fix prefixes of render functions. */
|
||||
#define cmark_node_render_html cmark_render_html
|
||||
#define cmark_node_render_xml cmark_render_xml
|
||||
#define cmark_node_render_man cmark_render_man
|
||||
|
||||
static SV*
|
||||
S_create_or_incref_node_sv(pTHX_ cmark_node *node) {
|
||||
SV *new_obj = NULL;
|
||||
|
||||
while (node) {
|
||||
SV *obj;
|
||||
HV *stash;
|
||||
|
||||
/* Look for existing object. */
|
||||
obj = (SV*)cmark_node_get_user_data(node);
|
||||
|
||||
if (obj) {
|
||||
/* Incref if found. */
|
||||
SvREFCNT_inc_simple_void_NN(obj);
|
||||
if (!new_obj) {
|
||||
new_obj = obj;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Create a new SV. */
|
||||
obj = newSViv(PTR2IV(node));
|
||||
cmark_node_set_user_data(node, obj);
|
||||
if (!new_obj) {
|
||||
new_obj = obj;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unfortunately, Perl doesn't offer an API function to bless an SV
|
||||
* without a reference. The following code is mostly copied from
|
||||
* sv_bless.
|
||||
*/
|
||||
SvOBJECT_on(obj);
|
||||
#if (PERL_VERSION <= 16)
|
||||
PL_sv_objcount++;
|
||||
#endif
|
||||
SvUPGRADE(obj, SVt_PVMG);
|
||||
stash = gv_stashpvn("CommonMark::Node", 16, GV_ADD);
|
||||
SvSTASH_set(obj, (HV*)SvREFCNT_inc(stash));
|
||||
|
||||
/* Recurse into parent. */
|
||||
node = cmark_node_parent(node);
|
||||
}
|
||||
|
||||
return new_obj;
|
||||
}
|
||||
|
||||
static void
|
||||
S_decref_node_sv(pTHX_ cmark_node *node) {
|
||||
SV *obj;
|
||||
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
obj = (SV*)cmark_node_get_user_data(node);
|
||||
if (!obj) {
|
||||
/* Should never happen. */
|
||||
croak("Internal error: node SV not found");
|
||||
}
|
||||
|
||||
SvREFCNT_dec_NN(obj);
|
||||
}
|
||||
|
||||
/* Find or create an SV for a cmark_node. */
|
||||
static SV*
|
||||
S_node2sv(pTHX_ cmark_node *node) {
|
||||
SV *obj;
|
||||
|
||||
if (!node) {
|
||||
return &PL_sv_undef;
|
||||
}
|
||||
|
||||
obj = S_create_or_incref_node_sv(aTHX_ node);
|
||||
|
||||
return newRV_noinc(obj);
|
||||
}
|
||||
|
||||
/* Transfer refcount from a node to another. */
|
||||
static void
|
||||
S_transfer_refcount(pTHX_ cmark_node *from, cmark_node *to) {
|
||||
if (from != to) {
|
||||
S_create_or_incref_node_sv(aTHX_ to);
|
||||
S_decref_node_sv(aTHX_ from);
|
||||
}
|
||||
}
|
||||
|
||||
/* Get C struct pointer from an SV argument. */
|
||||
static void*
|
||||
S_sv2c(pTHX_ SV *sv, const char *class_name, STRLEN len, CV *cv,
|
||||
const char *var_name) {
|
||||
if (!SvROK(sv) || !sv_derived_from_pvn(sv, class_name, len, 0)) {
|
||||
const char *sub_name = GvNAME(CvGV(cv));
|
||||
croak("%s: %s is not of type %s", sub_name, var_name, class_name);
|
||||
}
|
||||
return INT2PTR(void*, SvIV(SvRV(sv)));
|
||||
}
|
||||
|
||||
|
||||
MODULE = CommonMark PACKAGE = CommonMark PREFIX = cmark_
|
||||
|
||||
PROTOTYPES: DISABLE
|
||||
|
||||
BOOT:
|
||||
if (cmark_version != CMARK_VERSION) {
|
||||
warn("Compiled against libcmark %s, but runtime version is %s",
|
||||
CMARK_VERSION_STRING, cmark_version_string);
|
||||
}
|
||||
|
||||
char*
|
||||
cmark_markdown_to_html(package, string)
|
||||
SV *package = NO_INIT
|
||||
SV *string
|
||||
PREINIT:
|
||||
STRLEN len;
|
||||
const char *buffer;
|
||||
CODE:
|
||||
(void)package;
|
||||
buffer = SvPVutf8(string, len);
|
||||
RETVAL = cmark_markdown_to_html(buffer, len);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
cmark_node*
|
||||
cmark_parse_document(package, string)
|
||||
SV *package = NO_INIT
|
||||
SV *string
|
||||
PREINIT:
|
||||
STRLEN len;
|
||||
const char *buffer;
|
||||
CODE:
|
||||
(void)package;
|
||||
buffer = SvPVutf8(string, len);
|
||||
RETVAL = cmark_parse_document(buffer, len);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
cmark_node*
|
||||
cmark_parse_file(package, file)
|
||||
SV *package = NO_INIT
|
||||
SV *file
|
||||
PREINIT:
|
||||
PerlIO *perl_io;
|
||||
FILE *stream = NULL;
|
||||
CODE:
|
||||
(void)package;
|
||||
perl_io = IoIFP(sv_2io(file));
|
||||
if (perl_io) {
|
||||
stream = PerlIO_findFILE(perl_io);
|
||||
}
|
||||
if (!stream) {
|
||||
croak("parse_file: file is not a file handle");
|
||||
}
|
||||
RETVAL = cmark_parse_file(stream);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
int
|
||||
cmark_version(package)
|
||||
SV *package = NO_INIT
|
||||
CODE:
|
||||
(void)package;
|
||||
RETVAL = cmark_version;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
const char*
|
||||
cmark_version_string(package)
|
||||
SV *package = NO_INIT
|
||||
CODE:
|
||||
(void)package;
|
||||
RETVAL = cmark_version_string;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
int
|
||||
cmark_compile_time_version(package)
|
||||
SV *package = NO_INIT
|
||||
CODE:
|
||||
(void)package;
|
||||
RETVAL = CMARK_VERSION;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
const char*
|
||||
cmark_compile_time_version_string(package)
|
||||
SV *package = NO_INIT
|
||||
CODE:
|
||||
(void)package;
|
||||
RETVAL = CMARK_VERSION_STRING;
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
|
||||
MODULE = CommonMark PACKAGE = CommonMark::Node PREFIX = cmark_node_
|
||||
|
||||
cmark_node*
|
||||
new(package, type)
|
||||
SV *package = NO_INIT
|
||||
cmark_node_type type
|
||||
CODE:
|
||||
(void)package;
|
||||
RETVAL = cmark_node_new(type);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
DESTROY(cmark_node *node)
|
||||
CODE:
|
||||
cmark_node *parent = cmark_node_parent(node);
|
||||
if (parent) {
|
||||
cmark_node_set_user_data(node, NULL);
|
||||
S_decref_node_sv(aTHX_ parent);
|
||||
}
|
||||
else {
|
||||
cmark_node_free(node);
|
||||
}
|
||||
|
||||
cmark_iter*
|
||||
iterator(cmark_node *node)
|
||||
CODE:
|
||||
S_create_or_incref_node_sv(aTHX_ node);
|
||||
RETVAL = cmark_iter_new(node);
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
cmark_node*
|
||||
interface_get_node(cmark_node *node)
|
||||
INTERFACE:
|
||||
cmark_node_next
|
||||
cmark_node_previous
|
||||
cmark_node_parent
|
||||
cmark_node_first_child
|
||||
cmark_node_last_child
|
||||
|
||||
int
|
||||
interface_get_int(cmark_node *node)
|
||||
INTERFACE:
|
||||
cmark_node_get_type
|
||||
cmark_node_get_header_level
|
||||
cmark_node_get_list_type
|
||||
cmark_node_get_list_delim
|
||||
cmark_node_get_list_start
|
||||
cmark_node_get_list_tight
|
||||
cmark_node_get_start_line
|
||||
cmark_node_get_start_column
|
||||
cmark_node_get_end_line
|
||||
cmark_node_get_end_column
|
||||
|
||||
NO_OUTPUT int
|
||||
interface_set_int(cmark_node *node, int value)
|
||||
INTERFACE:
|
||||
cmark_node_set_header_level
|
||||
cmark_node_set_list_type
|
||||
cmark_node_set_list_delim
|
||||
cmark_node_set_list_start
|
||||
cmark_node_set_list_tight
|
||||
POSTCALL:
|
||||
if (!RETVAL) {
|
||||
croak("%s: invalid operation", GvNAME(CvGV(cv)));
|
||||
}
|
||||
|
||||
const char*
|
||||
interface_get_utf8(cmark_node *node)
|
||||
INTERFACE:
|
||||
cmark_node_get_type_string
|
||||
cmark_node_get_literal
|
||||
cmark_node_get_title
|
||||
cmark_node_get_url
|
||||
cmark_node_get_fence_info
|
||||
|
||||
NO_OUTPUT int
|
||||
interface_set_utf8(cmark_node *node, const char *value)
|
||||
INTERFACE:
|
||||
cmark_node_set_literal
|
||||
cmark_node_set_title
|
||||
cmark_node_set_url
|
||||
cmark_node_set_fence_info
|
||||
POSTCALL:
|
||||
if (!RETVAL) {
|
||||
croak("%s: invalid operation", GvNAME(CvGV(cv)));
|
||||
}
|
||||
|
||||
void
|
||||
cmark_node_unlink(cmark_node *node)
|
||||
PREINIT:
|
||||
cmark_node *old_parent;
|
||||
INIT:
|
||||
old_parent = cmark_node_parent(node);
|
||||
POSTCALL:
|
||||
S_decref_node_sv(aTHX_ old_parent);
|
||||
|
||||
NO_OUTPUT int
|
||||
interface_move_node(cmark_node *node, cmark_node *other)
|
||||
PREINIT:
|
||||
cmark_node *old_parent;
|
||||
cmark_node *new_parent;
|
||||
INIT:
|
||||
old_parent = cmark_node_parent(other);
|
||||
INTERFACE:
|
||||
cmark_node_insert_before
|
||||
cmark_node_insert_after
|
||||
cmark_node_prepend_child
|
||||
cmark_node_append_child
|
||||
POSTCALL:
|
||||
if (!RETVAL) {
|
||||
croak("%s: invalid operation", GvNAME(CvGV(cv)));
|
||||
}
|
||||
new_parent = cmark_node_parent(other);
|
||||
S_transfer_refcount(aTHX_ old_parent, new_parent);
|
||||
|
||||
char*
|
||||
interface_render(cmark_node *root, long options = 0)
|
||||
INTERFACE:
|
||||
cmark_node_render_html
|
||||
cmark_node_render_xml
|
||||
cmark_node_render_man
|
||||
|
||||
|
||||
MODULE = CommonMark PACKAGE = CommonMark::Iterator PREFIX = cmark_iter_
|
||||
|
||||
void
|
||||
DESTROY(cmark_iter *iter)
|
||||
CODE:
|
||||
S_decref_node_sv(aTHX_ cmark_iter_get_node(iter));
|
||||
S_decref_node_sv(aTHX_ cmark_iter_get_root(iter));
|
||||
cmark_iter_free(iter);
|
||||
|
||||
void
|
||||
cmark_iter_next(cmark_iter *iter)
|
||||
PREINIT:
|
||||
I32 gimme;
|
||||
cmark_node *old_node;
|
||||
cmark_event_type ev_type;
|
||||
PPCODE:
|
||||
gimme = GIMME_V;
|
||||
old_node = cmark_iter_get_node(iter);
|
||||
ev_type = cmark_iter_next(iter);
|
||||
|
||||
if (ev_type != CMARK_EVENT_DONE) {
|
||||
cmark_node *node = cmark_iter_get_node(iter);
|
||||
|
||||
ST(0) = sv_2mortal(newSViv((IV)ev_type));
|
||||
|
||||
if (gimme == G_ARRAY) {
|
||||
SV *obj = S_create_or_incref_node_sv(aTHX_ node);
|
||||
|
||||
/* A bit more efficient than S_transfer_refcount. */
|
||||
if (old_node != node) {
|
||||
S_decref_node_sv(aTHX_ old_node);
|
||||
SvREFCNT_inc_simple_void_NN(obj);
|
||||
}
|
||||
|
||||
ST(1) = sv_2mortal(newRV_noinc(obj));
|
||||
XSRETURN(2);
|
||||
}
|
||||
else {
|
||||
S_transfer_refcount(aTHX_ old_node, node);
|
||||
XSRETURN(1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
S_decref_node_sv(aTHX_ old_node);
|
||||
|
||||
if (gimme == G_ARRAY) {
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
else {
|
||||
ST(0) = sv_2mortal(newSViv((IV)ev_type));
|
||||
XSRETURN(1);
|
||||
}
|
||||
}
|
||||
|
||||
cmark_node*
|
||||
cmark_iter_get_node(cmark_iter *iter)
|
||||
|
||||
cmark_event_type
|
||||
cmark_iter_get_event_type(cmark_iter *iter)
|
||||
|
||||
void
|
||||
cmark_iter_reset(iter, node, event_type)
|
||||
cmark_iter *iter
|
||||
cmark_node *node
|
||||
cmark_event_type event_type
|
||||
PREINIT:
|
||||
cmark_node *old_node;
|
||||
INIT:
|
||||
old_node = cmark_iter_get_node(iter);
|
||||
S_transfer_refcount(aTHX_ old_node, node);
|
||||
|
||||
|
||||
MODULE = CommonMark PACKAGE = CommonMark::Parser PREFIX = cmark_parser_
|
||||
|
||||
cmark_parser*
|
||||
cmark_parser_new(package)
|
||||
SV *package = NO_INIT
|
||||
CODE:
|
||||
(void)package;
|
||||
RETVAL = cmark_parser_new();
|
||||
OUTPUT:
|
||||
RETVAL
|
||||
|
||||
void
|
||||
DESTROY(cmark_parser *parser)
|
||||
CODE:
|
||||
cmark_parser_free(parser);
|
||||
|
||||
void
|
||||
cmark_parser_feed(cmark_parser *parser, SV *string)
|
||||
PREINIT:
|
||||
STRLEN len;
|
||||
const char *buffer;
|
||||
CODE:
|
||||
buffer = SvPVutf8(string, len);
|
||||
cmark_parser_feed(parser, buffer, len);
|
||||
|
||||
cmark_node*
|
||||
cmark_parser_finish(cmark_parser *parser)
|
||||
|
||||
@@ -5,6 +5,8 @@ set -ex
|
||||
# Fetch all commits/refs needed to run our tests.
|
||||
git fetch origin master:master v2.0.0:v2.0.0 test/attributes:test/attributes test/master:test/master
|
||||
|
||||
sudo apt-get update
|
||||
|
||||
script/vendor-deb libicu48 libicu-dev
|
||||
if ruby -e 'exit RUBY_VERSION >= "2.0" && RUBY_VERSION < "2.1"'; then
|
||||
# Workaround for https://bugs.ruby-lang.org/issues/8074. We can't use this
|
||||
|
||||
@@ -14,7 +14,7 @@ class TestGrammars < Minitest::Test
|
||||
# must have a license that allows redistribution.
|
||||
"vendor/grammars/Sublime-Lasso",
|
||||
"vendor/grammars/Sublime-REBOL",
|
||||
"vendor/grammars/x86-assembly-textmate-bundle",
|
||||
"vendor/grammars/x86-assembly-textmate-bundle"
|
||||
].freeze
|
||||
|
||||
def setup
|
||||
|
||||
@@ -47,8 +47,10 @@ class TestHeuristcs < Minitest::Test
|
||||
# Candidate languages = ["Perl", "Prolog"]
|
||||
def test_pl_prolog_perl_by_heuristics
|
||||
assert_heuristics({
|
||||
"Prolog" => "Prolog/turing.pl",
|
||||
"Perl" => ["Perl/perl-test.t", "Perl/use5.pl"]
|
||||
"Prolog" => all_fixtures("Prolog/*.pl"),
|
||||
"Perl" => all_fixtures("Perl/*.pl"),
|
||||
"Perl" => ["Perl/perl-test.t"],
|
||||
"Perl6" => all_fixtures("Perl6/*.pl")
|
||||
})
|
||||
end
|
||||
|
||||
@@ -60,11 +62,13 @@ class TestHeuristcs < Minitest::Test
|
||||
})
|
||||
end
|
||||
|
||||
# Candidate languages = ["IDL", "Prolog"]
|
||||
def test_pro_prolog_idl_by_heuristics
|
||||
# Candidate languages = ["IDL", "Prolog", "QMake", "INI"]
|
||||
def test_pro_by_heuristics
|
||||
assert_heuristics({
|
||||
"Prolog" => "Prolog/logic-problem.pro",
|
||||
"IDL" => "IDL/mg_acosh.pro"
|
||||
"Prolog" => all_fixtures("Prolog", "*.pro"),
|
||||
"IDL" => all_fixtures("IDL", "*.pro"),
|
||||
"INI" => all_fixtures("INI", "*.pro"),
|
||||
"QMake" => all_fixtures("QMake", "*.pro")
|
||||
})
|
||||
end
|
||||
|
||||
|
||||
50
test/test_instrumentation.rb
Normal file
50
test/test_instrumentation.rb
Normal file
@@ -0,0 +1,50 @@
|
||||
require_relative "./helper"
|
||||
|
||||
class TestInstrumentation < Minitest::Test
|
||||
include Linguist
|
||||
|
||||
class LocalInstrumenter
|
||||
Event = Struct.new(:name, :args)
|
||||
|
||||
attr_reader :events
|
||||
|
||||
def initialize
|
||||
@events = []
|
||||
end
|
||||
|
||||
def instrument(name, *args)
|
||||
@events << Event.new(name, args)
|
||||
yield if block_given?
|
||||
end
|
||||
end
|
||||
|
||||
def setup
|
||||
Linguist.instrumenter = LocalInstrumenter.new
|
||||
end
|
||||
|
||||
def teardown
|
||||
Linguist.instrumenter = nil
|
||||
end
|
||||
|
||||
def test_detection_instrumentation_with_binary_blob
|
||||
binary_blob = fixture_blob("Binary/octocat.ai")
|
||||
Language.detect(binary_blob)
|
||||
|
||||
# Shouldn't instrument this (as it's binary)
|
||||
assert_equal 0, Linguist.instrumenter.events.size
|
||||
end
|
||||
|
||||
def test_modeline_instrumentation
|
||||
blob = fixture_blob("Data/Modelines/ruby")
|
||||
Language.detect(blob)
|
||||
|
||||
detect_event = Linguist.instrumenter.events.last
|
||||
detect_event_payload = detect_event[:args].first
|
||||
|
||||
assert_equal 3, Linguist.instrumenter.events.size
|
||||
assert_equal "linguist.detected", detect_event.name
|
||||
assert_equal Language['Ruby'], detect_event_payload[:language]
|
||||
assert_equal blob, detect_event_payload[:blob]
|
||||
assert_equal Linguist::Strategy::Modeline, detect_event_payload[:strategy]
|
||||
end
|
||||
end
|
||||
@@ -155,10 +155,6 @@ class TestLanguage < Minitest::Test
|
||||
assert_equal :prose, Language['Org'].type
|
||||
end
|
||||
|
||||
def test_other
|
||||
assert_nil Language['Brainfuck'].type
|
||||
end
|
||||
|
||||
def test_searchable
|
||||
assert Language['Ruby'].searchable?
|
||||
assert !Language['Gettext Catalog'].searchable?
|
||||
@@ -192,7 +188,7 @@ class TestLanguage < Minitest::Test
|
||||
assert_equal [], Language.find_by_extension('foo.rb')
|
||||
assert_equal [Language['Ruby']], Language.find_by_extension('rb')
|
||||
assert_equal [Language['Ruby']], Language.find_by_extension('.rb')
|
||||
assert_equal [Language['M'], Language['Mathematica'], Language['Matlab'], Language['Mercury'], Language['Objective-C']], Language.find_by_extension('.m')
|
||||
assert_equal [Language['M'], Language['MUF'], Language['Mathematica'], Language['Matlab'], Language['Mercury'], Language['Objective-C']], Language.find_by_extension('.m')
|
||||
end
|
||||
|
||||
def test_find_all_by_extension
|
||||
@@ -358,6 +354,15 @@ class TestLanguage < Minitest::Test
|
||||
assert missing.empty?, message
|
||||
end
|
||||
|
||||
def test_all_languages_have_type
|
||||
missing = Language.all.select { |language| language.type.nil? }
|
||||
message = "The following languages do not have a type listed in grammars.yml. Please add types for all new languages.\n"
|
||||
|
||||
width = missing.map { |language| language.name.length }.max
|
||||
message << missing.map { |language| sprintf("%-#{width}s", language.name) }.sort.join("\n")
|
||||
assert missing.empty?, message
|
||||
end
|
||||
|
||||
def test_all_languages_have_a_valid_ace_mode
|
||||
ace_fixture_path = File.join('test', 'fixtures', 'ace_modes.json')
|
||||
skip("No ace_modes.json file") unless File.exist?(ace_fixture_path)
|
||||
|
||||
@@ -12,7 +12,7 @@ class TestPedantic < Minitest::Test
|
||||
def test_extensions_are_sorted
|
||||
LANGUAGES.each do |name, language|
|
||||
extensions = language['extensions']
|
||||
assert_sorted extensions[1..-1] if extensions && extensions.size > 1
|
||||
assert_sorted extensions[1..-1].map(&:downcase) if extensions && extensions.size > 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class TestSamples < Minitest::Test
|
||||
if extnames = Samples.cache['extnames'][name]
|
||||
extnames.each do |extname|
|
||||
next if extname == '.script!'
|
||||
assert options['extensions'].index { |x| x.end_with? extname }, "#{name} has a sample with extension (#{extname}) that isn't explicitly defined in languages.yml"
|
||||
assert options['extensions'].index { |x| x.downcase.end_with? extname.downcase }, "#{name} has a sample with extension (#{extname.downcase}) that isn't explicitly defined in languages.yml"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -67,7 +67,7 @@ class TestSamples < Minitest::Test
|
||||
if language_matches.length > 1
|
||||
language_matches.each do |match|
|
||||
samples = "samples/#{match.name}/*#{extension}"
|
||||
assert Dir.glob(samples).any?, "Missing samples in #{samples.inspect}. See https://github.com/github/linguist/blob/master/CONTRIBUTING.md"
|
||||
assert Dir.glob(samples, File::FNM_CASEFOLD).any?, "Missing samples in #{samples.inspect}. See https://github.com/github/linguist/blob/master/CONTRIBUTING.md"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
1
vendor/grammars/Lean.tmbundle
vendored
Submodule
1
vendor/grammars/Lean.tmbundle
vendored
Submodule
Submodule vendor/grammars/Lean.tmbundle added at dc33b9450f
2
vendor/grammars/NimLime
vendored
2
vendor/grammars/NimLime
vendored
Submodule vendor/grammars/NimLime updated: fac6b182e8...ae0b75d99a
2
vendor/grammars/PHP-Twig.tmbundle
vendored
2
vendor/grammars/PHP-Twig.tmbundle
vendored
Submodule vendor/grammars/PHP-Twig.tmbundle updated: ad0f5147e6...f4f7529ac2
2
vendor/grammars/Stylus
vendored
2
vendor/grammars/Stylus
vendored
Submodule vendor/grammars/Stylus updated: b9214d1ffd...c060554eb8
2
vendor/grammars/Sublime-VimL
vendored
2
vendor/grammars/Sublime-VimL
vendored
Submodule vendor/grammars/Sublime-VimL updated: 366fdc64e3...4b23352ce5
2
vendor/grammars/SublimePapyrus
vendored
2
vendor/grammars/SublimePapyrus
vendored
Submodule vendor/grammars/SublimePapyrus updated: 27313007d9...6f4e954f35
1
vendor/grammars/ampl
vendored
Submodule
1
vendor/grammars/ampl
vendored
Submodule
Submodule vendor/grammars/ampl added at 2e399ebf4a
2
vendor/grammars/dart-sublime-bundle
vendored
2
vendor/grammars/dart-sublime-bundle
vendored
Submodule vendor/grammars/dart-sublime-bundle updated: d55b1d4278...65c9cd9a65
2
vendor/grammars/elixir-tmbundle
vendored
2
vendor/grammars/elixir-tmbundle
vendored
Submodule vendor/grammars/elixir-tmbundle updated: 9c63ff09bd...99910870bb
2
vendor/grammars/factor
vendored
2
vendor/grammars/factor
vendored
Submodule vendor/grammars/factor updated: ec896cd5ad...e237b49f83
2
vendor/grammars/fsharpbinding
vendored
2
vendor/grammars/fsharpbinding
vendored
Submodule vendor/grammars/fsharpbinding updated: 0cd6439b51...513db1c443
2
vendor/grammars/grace-tmbundle
vendored
2
vendor/grammars/grace-tmbundle
vendored
Submodule vendor/grammars/grace-tmbundle updated: acbf9a247c...2fba162ce7
2
vendor/grammars/haxe-sublime-bundle
vendored
2
vendor/grammars/haxe-sublime-bundle
vendored
Submodule vendor/grammars/haxe-sublime-bundle updated: 50c5aa0e10...84a4fab144
2
vendor/grammars/language-clojure
vendored
2
vendor/grammars/language-clojure
vendored
Submodule vendor/grammars/language-clojure updated: bae6eee855...51978f7d1b
2
vendor/grammars/language-gfm
vendored
2
vendor/grammars/language-gfm
vendored
Submodule vendor/grammars/language-gfm updated: 5f5df3064c...6ca2ea2ac5
2
vendor/grammars/language-javascript
vendored
2
vendor/grammars/language-javascript
vendored
Submodule vendor/grammars/language-javascript updated: d58edec655...da1fdb6949
2
vendor/grammars/latex.tmbundle
vendored
2
vendor/grammars/latex.tmbundle
vendored
Submodule vendor/grammars/latex.tmbundle updated: 669040b893...610ee6ef0d
2
vendor/grammars/mercury-tmlanguage
vendored
2
vendor/grammars/mercury-tmlanguage
vendored
Submodule vendor/grammars/mercury-tmlanguage updated: 1cb8e94922...cb57d42dbe
1
vendor/grammars/openscad.tmbundle
vendored
Submodule
1
vendor/grammars/openscad.tmbundle
vendored
Submodule
Submodule vendor/grammars/openscad.tmbundle added at 4b2bc0a8e1
1
vendor/grammars/oracle.tmbundle
vendored
Submodule
1
vendor/grammars/oracle.tmbundle
vendored
Submodule
Submodule vendor/grammars/oracle.tmbundle added at b41e6d33d6
2
vendor/grammars/powershell
vendored
2
vendor/grammars/powershell
vendored
Submodule vendor/grammars/powershell updated: 84fd97265c...0d9478d117
2
vendor/grammars/restructuredtext.tmbundle
vendored
2
vendor/grammars/restructuredtext.tmbundle
vendored
Submodule vendor/grammars/restructuredtext.tmbundle updated: 43fc7b1ff3...608d8bcdea
2
vendor/grammars/sublime-nginx
vendored
2
vendor/grammars/sublime-nginx
vendored
Submodule vendor/grammars/sublime-nginx updated: eee371d7f4...872afddd2d
1
vendor/grammars/sublime-varnish
vendored
Submodule
1
vendor/grammars/sublime-varnish
vendored
Submodule
Submodule vendor/grammars/sublime-varnish added at 9f0710bc4e
2
vendor/grammars/toml.tmbundle
vendored
2
vendor/grammars/toml.tmbundle
vendored
Submodule vendor/grammars/toml.tmbundle updated: cda2b74d0d...d261ef630a
1
vendor/grammars/xc.tmbundle
vendored
Submodule
1
vendor/grammars/xc.tmbundle
vendored
Submodule
Submodule vendor/grammars/xc.tmbundle added at 7239c92bd6
Reference in New Issue
Block a user