├── .gitignore ├── Cargo.toml ├── scripts ├── install_completion.sh └── bash_pinyin_completion ├── README.md ├── src └── main.rs ├── tests └── integration_tests.rs ├── Cargo.lock └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore test and build folder. 2 | /target 3 | /test -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "bash-pinyin-completion-rs" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | [dependencies] 7 | ib-matcher = { version = "0.4.0", features = ["pinyin"] } 8 | regex = "1.11.1" 9 | 10 | [dev-dependencies] 11 | assert_cmd = "2.0.17" 12 | predicates = "3.1.3" 13 | -------------------------------------------------------------------------------- /scripts/install_completion.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | cargo build --release 5 | 6 | # Check bash-completion 7 | if [ ! -d /etc/bash_completion.d ]; then 8 | echo "Directory /etc/bash_completion.d does not exist. Please install bash-completion first." 9 | exit 1 10 | fi 11 | 12 | # Install or upgrade the binary 13 | if [ -f /usr/bin/bash-pinyin-completion-rs ]; then 14 | echo "The binary /usr/bin/bash-pinyin-completion-rs already exists. Upgrading..." 15 | else 16 | echo "Installing binary..." 17 | fi 18 | sudo cp target/release/bash-pinyin-completion-rs /usr/bin/ 19 | 20 | # Install or upgrade the script 21 | if [ -f /etc/bash_completion.d/bash_pinyin_completion ]; then 22 | echo "The bash-completion script /etc/bash_completion.d/bash_pinyin_completion already exists. Upgrading..." 23 | else 24 | echo "Installing bash-completion script..." 25 | fi 26 | sudo cp scripts/bash_pinyin_completion /etc/bash_completion.d/ 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bash-pinyin-completion-rs 2 | 3 | Completion script for pinyin, matcher based on [IbPinyinLib](https://github.com/Chaoses-Ib/IbPinyinLib) 4 | 5 | ## Installation 6 | 7 | **Clone the project** 8 | 9 | ```bash 10 | git clone https://github.com/AOSC-Dev/bash-pinyin-completion-rs 11 | cd bash-pinyin-completion-rs 12 | ``` 13 | 14 | **Build and Install** 15 | 16 | Ensure that `bash-completion` and rust toolchains(cargo, etc.) are installed correctly. 17 | 18 | ```bash 19 | bash scripts/install_completion.sh 20 | ``` 21 | 22 | For better experience, add these to your inputrc (/etc/inputrc, ~/.inputrc): 23 | 24 | ``` 25 | set show-all-if-ambiguous on 26 | set menu-complete-display-prefix on 27 | TAB: menu-complete 28 | set colored-completion-prefix on 29 | set colored-stats on 30 | "\e[Z": menu-complete-backward 31 | ``` 32 | 33 | ## Requirements 34 | 35 | - bash-completion 36 | - rust toolchains 37 | 38 | ## Configuring Pinyin Schema 39 | 40 | `bash-pinyin-completion-rs` supports multiple Pinyin schemes: 41 | 42 | - **Quanpin**: Quanpin (full Pinyin) without tone marking - e.g., "zhongguo" for "中国" 43 | - **ShuangpinAbc**: Shuangpin (double Pinyin, or two-letter Pinyin) - 智能 ABC / Intelligent ABC scheme 44 | - **ShuangpinJiajia**: Shuangpin (double Pinyin, or two-letter Pinyin) - 拼音加加 / Pinyin Jiajia scheme 45 | - **ShuangpinMicrosoft**: Shuangpin (double Pinyin, or two-letter Pinyin) - 微软拼音 / MSPY scheme 46 | - **ShuangpinThunisoft**: Shuangpin (double Pinyin, or two-letter Pinyin) - 紫光拼音 / Thunisoft scheme 47 | - **ShuangpinXiaohe**: Shuangpin (double Pinyin, or two-letter Pinyin) - 小鹤 / Xiaohe scheme 48 | - **ShuangpinZrm**: Shuangpin (double Pinyin, or two-letter Pinyin) - 自然码 / Ziranma scheme 49 | 50 | You may configure the active scheme/schema with the `PINYIN_COMP_MODE` variable, 51 | typically set in `.bashrc`. If not set or value is invalid, `bash-pinyin-completion-rs` 52 | defaults to `Quanpin`. 53 | 54 | For example, to enable the 小鹤 / Xiaohe Shuangpin scheme: 55 | 56 | ```bash 57 | export PINYIN_COMP_MODE="ShuangpinXiaohe" 58 | ``` 59 | 60 | To use Quanpin together with Shuangpin (Xiaohe): 61 | 62 | ```bash 63 | export PINYIN_COMP_MODE="Quanpin,ShuangpinXiaohe" 64 | ``` 65 | 66 | ### Notes on Completion Modes 67 | 68 | - Prefix matching (e.g., "zg" for "中国") is enabled by default with Quanpin, 69 | but will be disabled if any Shuangpin schema is enabled. 70 | - Mixing Shuangpin schemas is not supported - 71 | if multiple Shuangpin schemas are enabled, only the first one will take effect. 72 | 73 | ## Bug report 74 | 75 | If you encounter any issues, please report them on the GitHub issues page. 76 | 77 | ## License 78 | 79 | This project is licensed under the GPLv3 License. See the [LICENSE](./LICENSE) file for details. 80 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use ib_matcher::{ 2 | matcher::{IbMatcher, PinyinMatchConfig}, 3 | pinyin::{PinyinNotation}, 4 | }; 5 | use std::env; 6 | use std::io::{BufRead, BufReader}; 7 | 8 | fn is_pure_english_path(s: &str) -> bool { 9 | // Consider a path "pure English" if every character is within a conservative 10 | // ASCII set that bash already handles well: letters, digits, '_', '-', '.', '/', '~'. 11 | // We also ignore trailing newlines/spaces (already trimmed). 12 | // Require at least one ASCII alphabetic letter so an empty string or just symbols 13 | // doesn't get suppressed accidentally. 14 | let mut has_alpha = false; 15 | for ch in s.chars() { 16 | if ch.is_ascii_alphabetic() { 17 | has_alpha = true; 18 | continue; 19 | } 20 | if ch.is_ascii_digit() || matches!(ch, '_' | '-' | '.' | '/' | '~') { 21 | continue; 22 | } 23 | // Any other (non ASCII or other punctuation) means it's not pure English. 24 | return false; 25 | } 26 | has_alpha 27 | } 28 | 29 | fn parse_pinyin_notation_env() -> PinyinNotation { 30 | let env_val = env::var("PINYIN_COMP_MODE").unwrap_or_default(); 31 | let mut notation = PinyinNotation::empty(); 32 | let mut shuangpin = Option::::None; 33 | 34 | for mode in env_val.split(',') { 35 | let mode = mode.trim(); 36 | match mode { 37 | "Quanpin" => { 38 | notation |= PinyinNotation::Ascii; 39 | } 40 | "ShuangpinAbc" => { 41 | shuangpin.get_or_insert(PinyinNotation::DiletterAbc); 42 | } 43 | "ShuangpinJiajia" => { 44 | shuangpin.get_or_insert(PinyinNotation::DiletterJiajia); 45 | } 46 | "ShuangpinMicrosoft" => { 47 | shuangpin.get_or_insert(PinyinNotation::DiletterMicrosoft); 48 | } 49 | "ShuangpinThunisoft" => { 50 | shuangpin.get_or_insert(PinyinNotation::DiletterThunisoft); 51 | } 52 | "ShuangpinXiaohe" => { 53 | shuangpin.get_or_insert(PinyinNotation::DiletterXiaohe); 54 | } 55 | "ShuangpinZrm" => { 56 | shuangpin.get_or_insert(PinyinNotation::DiletterZrm); 57 | } 58 | _ => {} 59 | } 60 | } 61 | 62 | notation |= shuangpin.unwrap_or(PinyinNotation::empty()); 63 | 64 | if notation.is_empty() { 65 | notation = PinyinNotation::Ascii; 66 | } 67 | 68 | if notation == PinyinNotation::Ascii { 69 | notation |= PinyinNotation::AsciiFirstLetter; 70 | } 71 | 72 | notation 73 | } 74 | 75 | fn main() { 76 | let args: Vec = std::env::args().collect(); 77 | // Print usage 78 | if args.len() < 2 { 79 | eprintln!("Usage: {} ", args[0]); 80 | std::process::exit(1); 81 | } 82 | 83 | let input: &str = &args[1]; 84 | let notation = parse_pinyin_notation_env(); 85 | let pinyin_config = PinyinMatchConfig::builder(notation).build(); 86 | 87 | let matcher = IbMatcher::builder(input) 88 | .starts_with(true) 89 | .pinyin(pinyin_config) 90 | .build(); 91 | 92 | let stdin = std::io::stdin(); 93 | let reader = BufReader::new(stdin.lock()); 94 | for line_result in reader.lines() { 95 | let candidate = match line_result { 96 | Ok(line) => line.trim_end().to_string(), 97 | Err(_) => { 98 | continue; 99 | } 100 | }; 101 | // Ignore Pure English Path 102 | if is_pure_english_path(&candidate) { 103 | continue; 104 | } 105 | if matcher.is_match(candidate.as_str()) { 106 | println!("{}", candidate); 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /tests/integration_tests.rs: -------------------------------------------------------------------------------- 1 | use assert_cmd::Command; 2 | use predicates::prelude::*; 3 | use std::collections::HashMap; 4 | 5 | #[derive(Debug, Clone)] 6 | pub struct TestCase<'a> { 7 | pub envs: Option<&'a HashMap<&'a str, &'a str>>, 8 | pub args: Vec<&'a str>, 9 | pub stdin: &'a str, 10 | pub stdout: &'a str, 11 | pub code: Option, 12 | } 13 | 14 | impl<'a> TestCase<'a> { 15 | pub fn run(self) { 16 | let mut cmd = Command::cargo_bin("bash-pinyin-completion-rs") 17 | .unwrap_or_else(|_| panic!("Failed to create command for test")); 18 | 19 | cmd.env_remove("PINYIN_COMP_MODE"); 20 | 21 | for (key, value) in self.envs.unwrap_or(&HashMap::new()) { 22 | cmd.env(key, value); 23 | } 24 | 25 | for arg in &self.args { 26 | cmd.arg(arg); 27 | } 28 | 29 | if !self.stdin.is_empty() { 30 | cmd.write_stdin(self.stdin); 31 | } 32 | 33 | let mut assertion = cmd.assert(); 34 | 35 | if let Some(exit_code) = self.code { 36 | assertion = assertion.code(exit_code); 37 | } else { 38 | assertion = assertion.success(); 39 | } 40 | 41 | assertion.stdout(predicate::eq(self.stdout)); 42 | } 43 | } 44 | 45 | impl<'a> Default for TestCase<'a> { 46 | fn default() -> Self { 47 | TestCase { 48 | envs: None, 49 | args: Vec::new(), 50 | stdin: "", 51 | stdout: "", 52 | code: None, 53 | } 54 | } 55 | } 56 | 57 | #[test] 58 | fn test_no_arguments() { 59 | TestCase { 60 | args: vec![], 61 | code: Some(1), 62 | ..Default::default() 63 | } 64 | .run(); 65 | } 66 | 67 | #[test] 68 | fn test_basic_pinyin_matching() { 69 | TestCase { 70 | args: vec!["ni"], 71 | stdin: "你好\n世界\n拼音\n测试\n", 72 | stdout: "你好\n", 73 | ..Default::default() 74 | } 75 | .run(); 76 | } 77 | 78 | #[test] 79 | fn test_pinyin_matching_with_multiple_candidates() { 80 | TestCase { 81 | args: vec!["shangh"], 82 | stdin: "上海\n深圳\n沈阳\n数据\n", 83 | stdout: "上海\n", 84 | ..Default::default() 85 | } 86 | .run(); 87 | } 88 | 89 | #[test] 90 | fn test_mixed() { 91 | TestCase { 92 | args: vec!["ce"], 93 | stdin: "测试\nhello\n世界\nworld\n测量\n", 94 | stdout: "测试\n测量\n", 95 | ..Default::default() 96 | } 97 | .run(); 98 | } 99 | 100 | #[test] 101 | fn test_prefix() { 102 | TestCase { 103 | args: vec!["py"], 104 | stdin: "拼音\n苹果\n朋友\n普通话\n", 105 | stdout: "拼音\n朋友\n", 106 | ..Default::default() 107 | } 108 | .run(); 109 | 110 | TestCase { 111 | args: vec!["zhongg"], 112 | stdin: "中国\n知识\n质量\n重要\n", 113 | stdout: "中国\n", 114 | ..Default::default() 115 | } 116 | .run(); 117 | } 118 | 119 | #[test] 120 | fn test_environment_variable_quanpin_mode() { 121 | use std::collections::HashMap; 122 | let mut env_vars = HashMap::new(); 123 | env_vars.insert("PINYIN_COMP_MODE", "Quanpin"); 124 | 125 | TestCase { 126 | envs: Some(&env_vars), 127 | args: vec!["zhongguo"], 128 | stdin: "中国\n中心\n", 129 | stdout: "中国\n", 130 | ..Default::default() 131 | } 132 | .run(); 133 | 134 | TestCase { 135 | envs: Some(&env_vars), 136 | args: vec!["zg"], 137 | stdin: "中国\n中心\n", 138 | stdout: "中国\n", 139 | ..Default::default() 140 | } 141 | .run(); 142 | } 143 | 144 | #[test] 145 | fn test_environment_variable_shuangpin_mode() { 146 | use std::collections::HashMap; 147 | let mut env_vars = HashMap::new(); 148 | env_vars.insert("PINYIN_COMP_MODE", "ShuangpinXiaohe"); 149 | 150 | TestCase { 151 | envs: Some(&env_vars), 152 | args: vec!["dl"], 153 | stdin: "中国\n大家\n", 154 | ..Default::default() 155 | } 156 | .run(); 157 | 158 | TestCase { 159 | envs: Some(&env_vars), 160 | args: vec!["dajx"], 161 | stdin: "中国\n大家\n", 162 | stdout: "大家\n", 163 | ..Default::default() 164 | } 165 | .run(); 166 | } 167 | 168 | #[test] 169 | fn test_environment_variable_mix_mode() { 170 | use std::collections::HashMap; 171 | let mut env_vars = HashMap::new(); 172 | env_vars.insert("PINYIN_COMP_MODE", "Quanpin,ShuangpinXiaohe"); 173 | 174 | TestCase { 175 | envs: Some(&env_vars), 176 | args: vec!["zhongguo"], 177 | stdin: "中国\n中心\n", 178 | stdout: "中国\n", 179 | ..Default::default() 180 | } 181 | .run(); 182 | 183 | TestCase { 184 | envs: Some(&env_vars), 185 | args: vec!["zg"], 186 | stdin: "中国\n中心\n", 187 | stdout: "", 188 | ..Default::default() 189 | } 190 | .run(); 191 | 192 | TestCase { 193 | envs: Some(&env_vars), 194 | args: vec!["vsxb"], 195 | stdin: "中国\n中心\n", 196 | stdout: "中心\n", 197 | ..Default::default() 198 | } 199 | .run(); 200 | } 201 | 202 | #[test] 203 | fn test_environment_variable_multiple_shuangpin_mode() { 204 | use std::collections::HashMap; 205 | let mut env_vars = HashMap::new(); 206 | env_vars.insert("PINYIN_COMP_MODE", "Quanpin,ShuangpinZrm,ShuangpinXiaohe"); 207 | 208 | TestCase { 209 | envs: Some(&env_vars), 210 | args: vec!["udpn"], 211 | stdin: "双拼\n用户\n", 212 | stdout: "双拼\n", 213 | ..Default::default() 214 | } 215 | .run(); 216 | 217 | TestCase { 218 | envs: Some(&env_vars), 219 | args: vec!["ulpb"], 220 | stdin: "双拼\n用户\n", 221 | stdout: "", 222 | ..Default::default() 223 | } 224 | .run(); 225 | } 226 | 227 | #[test] 228 | fn test_environment_variable_invalid_mode() { 229 | use std::collections::HashMap; 230 | let mut env_vars = HashMap::new(); 231 | env_vars.insert("PINYIN_COMP_MODE", "Invalid"); 232 | 233 | TestCase { 234 | envs: Some(&env_vars), 235 | args: vec!["shuangpin"], 236 | stdin: "双拼\n用户\n", 237 | stdout: "双拼\n", 238 | ..Default::default() 239 | } 240 | .run(); 241 | 242 | TestCase { 243 | envs: Some(&env_vars), 244 | args: vec!["yh"], 245 | stdin: "双拼\n用户\n", 246 | stdout: "用户\n", 247 | ..Default::default() 248 | } 249 | .run(); 250 | } 251 | 252 | #[test] 253 | fn test_whitespace_handling() { 254 | TestCase { 255 | args: vec!["ni"], 256 | stdin: "你好 世界\n 中国 \n你好\n", 257 | stdout: "你好 世界\n你好\n", 258 | ..Default::default() 259 | } 260 | .run(); 261 | } 262 | -------------------------------------------------------------------------------- /scripts/bash_pinyin_completion: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Anthon Open Source Community 4 | # Pinyin Completion Hook for Bash-Completion 5 | 6 | # Detect bash-completion 7 | if ! declare -F _comp_compgen__call_builtin &>/dev/null; then 8 | echo "No function _comp_compgen__call_builtin found. Please install bash-completion first." 9 | exit 1 10 | fi 11 | 12 | # Backup the original function 13 | eval "function __bak_comp_compgen__call_builtin() { $(declare -f _comp_compgen__call_builtin | tail -n +2) }" 14 | 15 | # Expand environment references ("$VAR", "${VAR}") inside completion prefixes 16 | __expand_env_refs() { 17 | local input="$1" 18 | # accumulate the expanded characters here 19 | local result="" 20 | local len=${#input} 21 | local i=0 22 | 23 | # Walk through every character 24 | while (( i < len )); do 25 | local ch="${input:i:1}" 26 | # Preserve escaped characters verbatim 27 | # "\$HOME" stays "$HOME" 28 | if [[ "$ch" == "\\" ]]; then 29 | ((i++)) 30 | if (( i < len )); then 31 | result+="${input:i:1}" 32 | ((i++)) 33 | fi 34 | continue 35 | fi 36 | 37 | # Handle environment references beginning with '$' 38 | if [[ "$ch" == '$' ]]; then 39 | ((i++)) 40 | if (( i >= len )); then 41 | result+='$' 42 | break 43 | fi 44 | 45 | ch="${input:i:1}" 46 | # Expand braces style 47 | # "${VAR}" 48 | if [[ "$ch" == '{' ]]; then 49 | ((i++)) 50 | local start=$i 51 | # Consume [A-Za-z0-9_] until we hit '}' or something else 52 | while (( i < len )); do 53 | ch="${input:i:1}" 54 | if [[ "$ch" =~ [A-Za-z0-9_] ]]; then 55 | ((i++)) 56 | continue 57 | fi 58 | break 59 | done 60 | local var_name="${input:start:i-start}" 61 | if [[ -z "$var_name" ]]; then 62 | result+='$' 63 | result+='{' 64 | continue 65 | fi 66 | if (( i < len )) && [[ "${input:i:1}" == '}' ]]; then 67 | ((i++)) 68 | # ${VAR} -> ${!VAR-} returns value or empty string. 69 | result+="${!var_name-}" 70 | else 71 | result+='$' 72 | result+='{' 73 | i=$start 74 | fi 75 | continue 76 | fi 77 | 78 | if [[ "$ch" =~ [A-Za-z_] ]]; then 79 | local start=$i 80 | while (( i < len )) && [[ "${input:i:1}" =~ [A-Za-z0-9_] ]]; do 81 | ((i++)) 82 | done 83 | local var_name="${input:start:i-start}" 84 | result+="${!var_name-}" 85 | continue 86 | fi 87 | 88 | # Handle positional parameters ($1) 89 | # or a few common special vars 90 | if [[ "$ch" =~ [0-9@*#?] ]]; then 91 | local special_name="$ch" 92 | ((i++)) 93 | result+="${!special_name-}" 94 | continue 95 | fi 96 | 97 | # Any other symbol 98 | result+='$' 99 | continue 100 | fi 101 | 102 | # Normal characters are copied through. 103 | result+="$ch" 104 | ((i++)) 105 | done 106 | 107 | printf '%s' "$result" 108 | } 109 | 110 | 111 | _comp_compgen__call_builtin() { 112 | __bak_comp_compgen__call_builtin "$@" 113 | local original_result=$? 114 | 115 | # Only add pinyin completion for file/directory completions 116 | local is_file_completion=false 117 | local compgen_args=("$@") 118 | 119 | # Check for file completion indicators 120 | local idx=0 121 | while [[ $idx -lt ${#compgen_args[@]} ]]; do 122 | local arg="${compgen_args[$idx]}" 123 | case "$arg" in 124 | -f|-d|-Afile|-Adirectory) 125 | is_file_completion=true 126 | break 127 | ;; 128 | -A) 129 | if (( idx + 1 < ${#compgen_args[@]} )); then 130 | local next_arg="${compgen_args[$((idx + 1))]}" 131 | if [[ "$next_arg" == "file" || "$next_arg" == "directory" ]]; then 132 | is_file_completion=true 133 | break 134 | fi 135 | fi 136 | ;; 137 | file|directory) 138 | is_file_completion=true 139 | break 140 | ;; 141 | esac 142 | ((idx++)) 143 | done 144 | 145 | # Also check if -W option is used with ${files[@]} or similar array expansion 146 | # which is a common pattern for file completion 147 | if [[ "$is_file_completion" == false ]]; then 148 | local i=0 149 | while [[ $i -lt ${#compgen_args[@]} ]]; do 150 | if [[ "${compgen_args[$i]}" == "-W" ]]; then 151 | local next_idx=$((i + 1)) 152 | if [[ $next_idx -lt ${#compgen_args[@]} ]]; then 153 | local word_arg="${compgen_args[$next_idx]}" 154 | # Check if it contains ${files or similar array patterns 155 | if [[ "$word_arg" == *'${files'* ]] || [[ "$word_arg" == *'${toks'* ]] || [[ "$word_arg" == *'$files'* ]] || [[ "$word_arg" == *'$toks'* ]]; then 156 | is_file_completion=true 157 | break 158 | fi 159 | fi 160 | fi 161 | ((i++)) 162 | done 163 | fi 164 | 165 | # If this looks like file completion, add pinyin matches 166 | if [[ "$is_file_completion" == true ]]; then 167 | _add_completion "$@" 168 | fi 169 | 170 | return $original_result 171 | } 172 | 173 | # Function to add completion results 174 | _add_completion() { 175 | # cur: bash-completion's working value for the current word. 176 | local cur 177 | 178 | eval "cur=${_cur}" 179 | # origin_cur: the user's raw buffer text before any expansion 180 | # including quotes or ~user prefixes. in other word, "snapshot". 181 | local orig_cur="$cur" 182 | # stripped_orig: an editable copy of orig_cur 183 | # used to compute orig_dirpart without mutating the original text. 184 | local stripped_orig="$orig_cur" 185 | local orig_dirpart="" 186 | if [[ "$stripped_orig" == "'"* || "$stripped_orig" == '"'* ]]; then 187 | stripped_orig="${stripped_orig:1}" 188 | fi 189 | if [[ "$stripped_orig" == */* ]]; then 190 | orig_dirpart="${stripped_orig%/*}" 191 | fi 192 | if [[ "$orig_dirpart" == "." && "${stripped_orig:0:2}" != "./" ]]; then 193 | orig_dirpart="" 194 | fi 195 | 196 | # Check if we have the necessary variables 197 | if [[ -z "${_cur-}" ]] || [[ -z "${_var-}" ]]; then 198 | return 199 | fi 200 | 201 | local var_name="$_var" 202 | 203 | # Skip empty 204 | [[ -z "$cur" ]] && return 205 | 206 | # perform bash-completion's normal expansions. 207 | _expand || return 0 208 | 209 | local dirpart basepart 210 | if [[ "${cur:0:1}" == "'" || "${cur:0:1}" == "\"" ]]; then 211 | dirpart="$(dirname -- "${cur:1}")" 212 | basepart="$(basename -- "${cur:1}")" 213 | else 214 | dirpart="$(dirname -- "$cur")" 215 | basepart="$(basename -- "$cur")" 216 | fi 217 | 218 | [[ "$dirpart" == "." && "${cur:0:2}" != "./" ]] && dirpart="" 219 | 220 | # Expand environemnt variables 221 | # dirpart_lookup: save the true path after expanded 222 | # NOTE: in the end, the path prefix will be rollbacked to "snapshot". 223 | local dirpart_lookup="$dirpart" 224 | if [[ -n "$dirpart_lookup" && "$dirpart_lookup" == *'$'* ]]; then 225 | local expanded_lookup 226 | expanded_lookup="$(__expand_env_refs "$dirpart_lookup")" 227 | if [[ -n "$expanded_lookup" ]]; then 228 | dirpart_lookup="$expanded_lookup" 229 | fi 230 | fi 231 | 232 | local savedPWD="$PWD" 233 | local resolved_dir 234 | local compgen_opts=(-f) 235 | 236 | local is_dir_only=false 237 | for arg in "$@"; do 238 | if [[ "$arg" == "-d" ]]; then 239 | is_dir_only=true 240 | compgen_opts=(-d) 241 | break 242 | fi 243 | done 244 | 245 | if [[ -n "$dirpart_lookup" ]]; then 246 | # Resolve the working directory for compgen use realpath, but remember 247 | # the original textual prefix so completions can stay aligned with what the user typed. 248 | resolved_dir="$(realpath -- "$dirpart_lookup" 2>/dev/null)" 249 | if [[ -d "$resolved_dir" ]]; then 250 | cd -- "$resolved_dir" 2>/dev/null || return 251 | else 252 | cd "$savedPWD" || return 253 | return 254 | fi 255 | fi 256 | 257 | # Kernel 258 | local -a pinyin_matched 259 | if [[ "$is_dir_only" == true ]]; then 260 | mapfile -t pinyin_matched < <( 261 | compgen -d -- 2>/dev/null | 262 | bash-pinyin-completion-rs "$basepart" 2>/dev/null 263 | ) 264 | else 265 | mapfile -t pinyin_matched < <( 266 | compgen -f -- 2>/dev/null | 267 | bash-pinyin-completion-rs "$basepart" 2>/dev/null 268 | ) 269 | fi 270 | 271 | # Restore directory 272 | cd "$savedPWD" || return 273 | 274 | if [[ ${#pinyin_matched[@]} -gt 0 ]]; then 275 | local display_dirpart="$dirpart" 276 | if [[ -n "$orig_dirpart" ]]; then 277 | # When the user typed something like ~user/src, prefer their original prefix for display 278 | # instead of the realpath directory we temp into. 279 | # "snapshot" we saved before comes in handy here. 280 | display_dirpart="$orig_dirpart" 281 | fi 282 | if [[ -n "$display_dirpart" ]]; then 283 | local sep="/" 284 | [[ "$display_dirpart" == "/" ]] && sep="" 285 | for i in "${!pinyin_matched[@]}"; do 286 | pinyin_matched[$i]="${display_dirpart}${sep}${pinyin_matched[$i]}" 287 | done 288 | fi 289 | 290 | local orig_check="$orig_cur" 291 | if [[ "$orig_check" == "'"* || "$orig_check" == '"'* ]]; then 292 | orig_check="${orig_check:1}" 293 | fi 294 | if [[ "$orig_check" == ~* ]]; then 295 | # Map the tilde-prefix the user entered back onto the filesystem 296 | # path produced by compgen so the completion output preserves the symbolic form. 297 | local tilde_prefix="${orig_check%%/*}" 298 | local expanded_prefix="" 299 | if [[ "$tilde_prefix" == "~" ]]; then 300 | expanded_prefix="$HOME" 301 | elif [[ "$tilde_prefix" == ~+ ]]; then 302 | expanded_prefix="$PWD" 303 | elif [[ "$tilde_prefix" == ~- ]]; then 304 | expanded_prefix="${OLDPWD-}" 305 | else 306 | local tilde_user="${tilde_prefix:1}" 307 | if [[ -n "$tilde_user" ]]; then 308 | # Find the user from passwd. 309 | expanded_prefix="$(getent passwd "$tilde_user" 2>/dev/null | cut -d: -f6)" 310 | fi 311 | fi 312 | if [[ -n "$expanded_prefix" ]]; then 313 | for i in "${!pinyin_matched[@]}"; do 314 | if [[ "${pinyin_matched[$i]}" == "$expanded_prefix" ]]; then 315 | # Exact home directory. 316 | pinyin_matched[$i]="$tilde_prefix" 317 | elif [[ "${pinyin_matched[$i]}" == "$expanded_prefix"/* ]]; then 318 | local suffix="${pinyin_matched[$i]#"$expanded_prefix/"}" 319 | # Join path under the user home. 320 | pinyin_matched[$i]="$tilde_prefix/$suffix" 321 | fi 322 | done 323 | fi 324 | fi 325 | 326 | local current_results_var="current_results" 327 | eval "local -a $current_results_var=(\"\${$var_name[@]}\")" 328 | 329 | # Merge results and remove duplicates 330 | local -a all_results 331 | eval "all_results=(\"\${$current_results_var[@]}\" \"\${pinyin_matched[@]}\")" 332 | 333 | declare -A seen 334 | local -a unique_results=() 335 | for item in "${all_results[@]}"; do 336 | if [[ -z "${seen[$item]}" ]]; then 337 | seen["$item"]=1 338 | unique_results+=("$item") 339 | fi 340 | done 341 | 342 | eval "$var_name=(\"\${unique_results[@]}\")" 343 | fi 344 | } 345 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 4 4 | 5 | [[package]] 6 | name = "aho-corasick" 7 | version = "1.1.3" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" 10 | dependencies = [ 11 | "memchr", 12 | ] 13 | 14 | [[package]] 15 | name = "anstyle" 16 | version = "1.0.11" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" 19 | 20 | [[package]] 21 | name = "arraystring" 22 | version = "0.3.0" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "4d517c467117e1d8ca795bc8cc90857ff7f79790cca0e26f6e9462694ece0185" 25 | dependencies = [ 26 | "typenum", 27 | ] 28 | 29 | [[package]] 30 | name = "assert_cmd" 31 | version = "2.0.17" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "2bd389a4b2970a01282ee455294913c0a43724daedcd1a24c3eb0ec1c1320b66" 34 | dependencies = [ 35 | "anstyle", 36 | "bstr", 37 | "doc-comment", 38 | "libc", 39 | "predicates", 40 | "predicates-core", 41 | "predicates-tree", 42 | "wait-timeout", 43 | ] 44 | 45 | [[package]] 46 | name = "autocfg" 47 | version = "1.4.0" 48 | source = "registry+https://github.com/rust-lang/crates.io-index" 49 | checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" 50 | 51 | [[package]] 52 | name = "bash-pinyin-completion-rs" 53 | version = "0.1.0" 54 | dependencies = [ 55 | "assert_cmd", 56 | "ib-matcher", 57 | "predicates", 58 | "regex", 59 | ] 60 | 61 | [[package]] 62 | name = "beef" 63 | version = "0.5.2" 64 | source = "registry+https://github.com/rust-lang/crates.io-index" 65 | checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" 66 | 67 | [[package]] 68 | name = "bitflags" 69 | version = "2.9.1" 70 | source = "registry+https://github.com/rust-lang/crates.io-index" 71 | checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" 72 | 73 | [[package]] 74 | name = "bon" 75 | version = "3.6.4" 76 | source = "registry+https://github.com/rust-lang/crates.io-index" 77 | checksum = "f61138465baf186c63e8d9b6b613b508cd832cba4ce93cf37ce5f096f91ac1a6" 78 | dependencies = [ 79 | "bon-macros", 80 | "rustversion", 81 | ] 82 | 83 | [[package]] 84 | name = "bon-macros" 85 | version = "3.6.4" 86 | source = "registry+https://github.com/rust-lang/crates.io-index" 87 | checksum = "40d1dad34aa19bf02295382f08d9bc40651585bd497266831d40ee6296fb49ca" 88 | dependencies = [ 89 | "darling", 90 | "ident_case", 91 | "prettyplease", 92 | "proc-macro2", 93 | "quote", 94 | "rustversion", 95 | "syn 2.0.104", 96 | ] 97 | 98 | [[package]] 99 | name = "bstr" 100 | version = "1.12.0" 101 | source = "registry+https://github.com/rust-lang/crates.io-index" 102 | checksum = "234113d19d0d7d613b40e86fb654acf958910802bcceab913a4f9e7cda03b1a4" 103 | dependencies = [ 104 | "memchr", 105 | "regex-automata", 106 | "serde", 107 | ] 108 | 109 | [[package]] 110 | name = "byteorder" 111 | version = "1.5.0" 112 | source = "registry+https://github.com/rust-lang/crates.io-index" 113 | checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" 114 | 115 | [[package]] 116 | name = "cc" 117 | version = "1.2.36" 118 | source = "registry+https://github.com/rust-lang/crates.io-index" 119 | checksum = "5252b3d2648e5eedbc1a6f501e3c795e07025c1e93bbf8bbdd6eef7f447a6d54" 120 | dependencies = [ 121 | "find-msvc-tools", 122 | "jobserver", 123 | "libc", 124 | "shlex", 125 | ] 126 | 127 | [[package]] 128 | name = "cfg-if" 129 | version = "1.0.3" 130 | source = "registry+https://github.com/rust-lang/crates.io-index" 131 | checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" 132 | 133 | [[package]] 134 | name = "daachorse" 135 | version = "1.0.0" 136 | source = "registry+https://github.com/rust-lang/crates.io-index" 137 | checksum = "63b7ef7a4be509357f4804d0a22e830daddb48f19fd604e4ad32ddce04a94c36" 138 | 139 | [[package]] 140 | name = "darling" 141 | version = "0.20.11" 142 | source = "registry+https://github.com/rust-lang/crates.io-index" 143 | checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" 144 | dependencies = [ 145 | "darling_core", 146 | "darling_macro", 147 | ] 148 | 149 | [[package]] 150 | name = "darling_core" 151 | version = "0.20.11" 152 | source = "registry+https://github.com/rust-lang/crates.io-index" 153 | checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" 154 | dependencies = [ 155 | "fnv", 156 | "ident_case", 157 | "proc-macro2", 158 | "quote", 159 | "strsim", 160 | "syn 2.0.104", 161 | ] 162 | 163 | [[package]] 164 | name = "darling_macro" 165 | version = "0.20.11" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" 168 | dependencies = [ 169 | "darling_core", 170 | "quote", 171 | "syn 2.0.104", 172 | ] 173 | 174 | [[package]] 175 | name = "difflib" 176 | version = "0.4.0" 177 | source = "registry+https://github.com/rust-lang/crates.io-index" 178 | checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8" 179 | 180 | [[package]] 181 | name = "doc-comment" 182 | version = "0.3.3" 183 | source = "registry+https://github.com/rust-lang/crates.io-index" 184 | checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" 185 | 186 | [[package]] 187 | name = "either" 188 | version = "1.15.0" 189 | source = "registry+https://github.com/rust-lang/crates.io-index" 190 | checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" 191 | 192 | [[package]] 193 | name = "equivalent" 194 | version = "1.0.2" 195 | source = "registry+https://github.com/rust-lang/crates.io-index" 196 | checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" 197 | 198 | [[package]] 199 | name = "find-msvc-tools" 200 | version = "0.1.1" 201 | source = "registry+https://github.com/rust-lang/crates.io-index" 202 | checksum = "7fd99930f64d146689264c637b5af2f0233a933bef0d8570e2526bf9e083192d" 203 | 204 | [[package]] 205 | name = "float-cmp" 206 | version = "0.10.0" 207 | source = "registry+https://github.com/rust-lang/crates.io-index" 208 | checksum = "b09cf3155332e944990140d967ff5eceb70df778b34f77d8075db46e4704e6d8" 209 | dependencies = [ 210 | "num-traits", 211 | ] 212 | 213 | [[package]] 214 | name = "fnv" 215 | version = "1.0.7" 216 | source = "registry+https://github.com/rust-lang/crates.io-index" 217 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 218 | 219 | [[package]] 220 | name = "getrandom" 221 | version = "0.3.3" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" 224 | dependencies = [ 225 | "cfg-if", 226 | "libc", 227 | "r-efi", 228 | "wasi", 229 | ] 230 | 231 | [[package]] 232 | name = "hashbrown" 233 | version = "0.15.5" 234 | source = "registry+https://github.com/rust-lang/crates.io-index" 235 | checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" 236 | 237 | [[package]] 238 | name = "ib-matcher" 239 | version = "0.4.0" 240 | source = "registry+https://github.com/rust-lang/crates.io-index" 241 | checksum = "5319f5e36b549be48c5e3d05f6efd73eec21cc32d8e63e1ec6cf9c7e9325a9dc" 242 | dependencies = [ 243 | "aho-corasick", 244 | "arraystring", 245 | "bitflags", 246 | "bon", 247 | "ib-romaji", 248 | "ib-unicode", 249 | "itertools", 250 | "logos", 251 | "regex-automata", 252 | "regex-syntax", 253 | ] 254 | 255 | [[package]] 256 | name = "ib-romaji" 257 | version = "0.1.2" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "3bbdac9da9f43ee069474f5124090403a3993add9541787813d8a3f55fbf022d" 260 | dependencies = [ 261 | "bon", 262 | "daachorse", 263 | "ib-unicode", 264 | "include-bytes-zstd", 265 | ] 266 | 267 | [[package]] 268 | name = "ib-unicode" 269 | version = "0.2.1" 270 | source = "registry+https://github.com/rust-lang/crates.io-index" 271 | checksum = "2db8f0e0751631f4edac5388c7bccad62da9614713811b8de512b40b4e85380d" 272 | dependencies = [ 273 | "bstr", 274 | "memchr", 275 | ] 276 | 277 | [[package]] 278 | name = "ident_case" 279 | version = "1.0.1" 280 | source = "registry+https://github.com/rust-lang/crates.io-index" 281 | checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" 282 | 283 | [[package]] 284 | name = "include-bytes-zstd" 285 | version = "0.1.0" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "337f22cf5b052ce0d8bdb08d267ecb9979645d32fe5978ac26e2a28c747eccce" 288 | dependencies = [ 289 | "include-bytes-zstd-macro", 290 | "ruzstd", 291 | ] 292 | 293 | [[package]] 294 | name = "include-bytes-zstd-macro" 295 | version = "0.1.0" 296 | source = "registry+https://github.com/rust-lang/crates.io-index" 297 | checksum = "0663850f077a70c69671296dab8b5770421ef81a761f9cacff760b86be1fb077" 298 | dependencies = [ 299 | "proc-macro-crate", 300 | "syn 1.0.109", 301 | "zstd", 302 | ] 303 | 304 | [[package]] 305 | name = "indexmap" 306 | version = "2.11.1" 307 | source = "registry+https://github.com/rust-lang/crates.io-index" 308 | checksum = "206a8042aec68fa4a62e8d3f7aa4ceb508177d9324faf261e1959e495b7a1921" 309 | dependencies = [ 310 | "equivalent", 311 | "hashbrown", 312 | ] 313 | 314 | [[package]] 315 | name = "itertools" 316 | version = "0.14.0" 317 | source = "registry+https://github.com/rust-lang/crates.io-index" 318 | checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" 319 | dependencies = [ 320 | "either", 321 | ] 322 | 323 | [[package]] 324 | name = "jobserver" 325 | version = "0.1.34" 326 | source = "registry+https://github.com/rust-lang/crates.io-index" 327 | checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" 328 | dependencies = [ 329 | "getrandom", 330 | "libc", 331 | ] 332 | 333 | [[package]] 334 | name = "lazy_static" 335 | version = "1.5.0" 336 | source = "registry+https://github.com/rust-lang/crates.io-index" 337 | checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" 338 | 339 | [[package]] 340 | name = "libc" 341 | version = "0.2.173" 342 | source = "registry+https://github.com/rust-lang/crates.io-index" 343 | checksum = "d8cfeafaffdbc32176b64fb251369d52ea9f0a8fbc6f8759edffef7b525d64bb" 344 | 345 | [[package]] 346 | name = "logos" 347 | version = "0.15.1" 348 | source = "registry+https://github.com/rust-lang/crates.io-index" 349 | checksum = "ff472f899b4ec2d99161c51f60ff7075eeb3097069a36050d8037a6325eb8154" 350 | dependencies = [ 351 | "logos-derive", 352 | ] 353 | 354 | [[package]] 355 | name = "logos-codegen" 356 | version = "0.15.1" 357 | source = "registry+https://github.com/rust-lang/crates.io-index" 358 | checksum = "192a3a2b90b0c05b27a0b2c43eecdb7c415e29243acc3f89cc8247a5b693045c" 359 | dependencies = [ 360 | "beef", 361 | "fnv", 362 | "lazy_static", 363 | "proc-macro2", 364 | "quote", 365 | "regex-syntax", 366 | "rustc_version", 367 | "syn 2.0.104", 368 | ] 369 | 370 | [[package]] 371 | name = "logos-derive" 372 | version = "0.15.1" 373 | source = "registry+https://github.com/rust-lang/crates.io-index" 374 | checksum = "605d9697bcd5ef3a42d38efc51541aa3d6a4a25f7ab6d1ed0da5ac632a26b470" 375 | dependencies = [ 376 | "logos-codegen", 377 | ] 378 | 379 | [[package]] 380 | name = "memchr" 381 | version = "2.7.4" 382 | source = "registry+https://github.com/rust-lang/crates.io-index" 383 | checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" 384 | 385 | [[package]] 386 | name = "normalize-line-endings" 387 | version = "0.3.0" 388 | source = "registry+https://github.com/rust-lang/crates.io-index" 389 | checksum = "61807f77802ff30975e01f4f071c8ba10c022052f98b3294119f3e615d13e5be" 390 | 391 | [[package]] 392 | name = "num-traits" 393 | version = "0.2.19" 394 | source = "registry+https://github.com/rust-lang/crates.io-index" 395 | checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" 396 | dependencies = [ 397 | "autocfg", 398 | ] 399 | 400 | [[package]] 401 | name = "once_cell" 402 | version = "1.21.3" 403 | source = "registry+https://github.com/rust-lang/crates.io-index" 404 | checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" 405 | 406 | [[package]] 407 | name = "pkg-config" 408 | version = "0.3.32" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" 411 | 412 | [[package]] 413 | name = "predicates" 414 | version = "3.1.3" 415 | source = "registry+https://github.com/rust-lang/crates.io-index" 416 | checksum = "a5d19ee57562043d37e82899fade9a22ebab7be9cef5026b07fda9cdd4293573" 417 | dependencies = [ 418 | "anstyle", 419 | "difflib", 420 | "float-cmp", 421 | "normalize-line-endings", 422 | "predicates-core", 423 | "regex", 424 | ] 425 | 426 | [[package]] 427 | name = "predicates-core" 428 | version = "1.0.9" 429 | source = "registry+https://github.com/rust-lang/crates.io-index" 430 | checksum = "727e462b119fe9c93fd0eb1429a5f7647394014cf3c04ab2c0350eeb09095ffa" 431 | 432 | [[package]] 433 | name = "predicates-tree" 434 | version = "1.0.12" 435 | source = "registry+https://github.com/rust-lang/crates.io-index" 436 | checksum = "72dd2d6d381dfb73a193c7fca536518d7caee39fc8503f74e7dc0be0531b425c" 437 | dependencies = [ 438 | "predicates-core", 439 | "termtree", 440 | ] 441 | 442 | [[package]] 443 | name = "prettyplease" 444 | version = "0.2.35" 445 | source = "registry+https://github.com/rust-lang/crates.io-index" 446 | checksum = "061c1221631e079b26479d25bbf2275bfe5917ae8419cd7e34f13bfc2aa7539a" 447 | dependencies = [ 448 | "proc-macro2", 449 | "syn 2.0.104", 450 | ] 451 | 452 | [[package]] 453 | name = "proc-macro-crate" 454 | version = "1.3.1" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" 457 | dependencies = [ 458 | "once_cell", 459 | "toml_edit", 460 | ] 461 | 462 | [[package]] 463 | name = "proc-macro2" 464 | version = "1.0.95" 465 | source = "registry+https://github.com/rust-lang/crates.io-index" 466 | checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" 467 | dependencies = [ 468 | "unicode-ident", 469 | ] 470 | 471 | [[package]] 472 | name = "quote" 473 | version = "1.0.40" 474 | source = "registry+https://github.com/rust-lang/crates.io-index" 475 | checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" 476 | dependencies = [ 477 | "proc-macro2", 478 | ] 479 | 480 | [[package]] 481 | name = "r-efi" 482 | version = "5.3.0" 483 | source = "registry+https://github.com/rust-lang/crates.io-index" 484 | checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" 485 | 486 | [[package]] 487 | name = "regex" 488 | version = "1.11.1" 489 | source = "registry+https://github.com/rust-lang/crates.io-index" 490 | checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" 491 | dependencies = [ 492 | "aho-corasick", 493 | "memchr", 494 | "regex-automata", 495 | "regex-syntax", 496 | ] 497 | 498 | [[package]] 499 | name = "regex-automata" 500 | version = "0.4.9" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" 503 | dependencies = [ 504 | "aho-corasick", 505 | "memchr", 506 | "regex-syntax", 507 | ] 508 | 509 | [[package]] 510 | name = "regex-syntax" 511 | version = "0.8.5" 512 | source = "registry+https://github.com/rust-lang/crates.io-index" 513 | checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" 514 | 515 | [[package]] 516 | name = "rustc_version" 517 | version = "0.4.1" 518 | source = "registry+https://github.com/rust-lang/crates.io-index" 519 | checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" 520 | dependencies = [ 521 | "semver", 522 | ] 523 | 524 | [[package]] 525 | name = "rustversion" 526 | version = "1.0.21" 527 | source = "registry+https://github.com/rust-lang/crates.io-index" 528 | checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" 529 | 530 | [[package]] 531 | name = "ruzstd" 532 | version = "0.3.1" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "9a15e661f0f9dac21f3494fe5d23a6338c0ac116a2d22c2b63010acd89467ffe" 535 | dependencies = [ 536 | "byteorder", 537 | "thiserror", 538 | "twox-hash", 539 | ] 540 | 541 | [[package]] 542 | name = "semver" 543 | version = "1.0.26" 544 | source = "registry+https://github.com/rust-lang/crates.io-index" 545 | checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" 546 | 547 | [[package]] 548 | name = "serde" 549 | version = "1.0.219" 550 | source = "registry+https://github.com/rust-lang/crates.io-index" 551 | checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" 552 | dependencies = [ 553 | "serde_derive", 554 | ] 555 | 556 | [[package]] 557 | name = "serde_derive" 558 | version = "1.0.219" 559 | source = "registry+https://github.com/rust-lang/crates.io-index" 560 | checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" 561 | dependencies = [ 562 | "proc-macro2", 563 | "quote", 564 | "syn 2.0.104", 565 | ] 566 | 567 | [[package]] 568 | name = "shlex" 569 | version = "1.3.0" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" 572 | 573 | [[package]] 574 | name = "static_assertions" 575 | version = "1.1.0" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 578 | 579 | [[package]] 580 | name = "strsim" 581 | version = "0.11.1" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" 584 | 585 | [[package]] 586 | name = "syn" 587 | version = "1.0.109" 588 | source = "registry+https://github.com/rust-lang/crates.io-index" 589 | checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 590 | dependencies = [ 591 | "proc-macro2", 592 | "quote", 593 | "unicode-ident", 594 | ] 595 | 596 | [[package]] 597 | name = "syn" 598 | version = "2.0.104" 599 | source = "registry+https://github.com/rust-lang/crates.io-index" 600 | checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" 601 | dependencies = [ 602 | "proc-macro2", 603 | "quote", 604 | "unicode-ident", 605 | ] 606 | 607 | [[package]] 608 | name = "termtree" 609 | version = "0.5.1" 610 | source = "registry+https://github.com/rust-lang/crates.io-index" 611 | checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683" 612 | 613 | [[package]] 614 | name = "thiserror" 615 | version = "1.0.69" 616 | source = "registry+https://github.com/rust-lang/crates.io-index" 617 | checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" 618 | dependencies = [ 619 | "thiserror-impl", 620 | ] 621 | 622 | [[package]] 623 | name = "thiserror-impl" 624 | version = "1.0.69" 625 | source = "registry+https://github.com/rust-lang/crates.io-index" 626 | checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" 627 | dependencies = [ 628 | "proc-macro2", 629 | "quote", 630 | "syn 2.0.104", 631 | ] 632 | 633 | [[package]] 634 | name = "toml_datetime" 635 | version = "0.6.11" 636 | source = "registry+https://github.com/rust-lang/crates.io-index" 637 | checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" 638 | 639 | [[package]] 640 | name = "toml_edit" 641 | version = "0.19.15" 642 | source = "registry+https://github.com/rust-lang/crates.io-index" 643 | checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" 644 | dependencies = [ 645 | "indexmap", 646 | "toml_datetime", 647 | "winnow", 648 | ] 649 | 650 | [[package]] 651 | name = "twox-hash" 652 | version = "1.6.3" 653 | source = "registry+https://github.com/rust-lang/crates.io-index" 654 | checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" 655 | dependencies = [ 656 | "cfg-if", 657 | "static_assertions", 658 | ] 659 | 660 | [[package]] 661 | name = "typenum" 662 | version = "1.18.0" 663 | source = "registry+https://github.com/rust-lang/crates.io-index" 664 | checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" 665 | 666 | [[package]] 667 | name = "unicode-ident" 668 | version = "1.0.18" 669 | source = "registry+https://github.com/rust-lang/crates.io-index" 670 | checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" 671 | 672 | [[package]] 673 | name = "wait-timeout" 674 | version = "0.2.1" 675 | source = "registry+https://github.com/rust-lang/crates.io-index" 676 | checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" 677 | dependencies = [ 678 | "libc", 679 | ] 680 | 681 | [[package]] 682 | name = "wasi" 683 | version = "0.14.5+wasi-0.2.4" 684 | source = "registry+https://github.com/rust-lang/crates.io-index" 685 | checksum = "a4494f6290a82f5fe584817a676a34b9d6763e8d9d18204009fb31dceca98fd4" 686 | dependencies = [ 687 | "wasip2", 688 | ] 689 | 690 | [[package]] 691 | name = "wasip2" 692 | version = "1.0.0+wasi-0.2.4" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "03fa2761397e5bd52002cd7e73110c71af2109aca4e521a9f40473fe685b0a24" 695 | dependencies = [ 696 | "wit-bindgen", 697 | ] 698 | 699 | [[package]] 700 | name = "winnow" 701 | version = "0.5.40" 702 | source = "registry+https://github.com/rust-lang/crates.io-index" 703 | checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" 704 | dependencies = [ 705 | "memchr", 706 | ] 707 | 708 | [[package]] 709 | name = "wit-bindgen" 710 | version = "0.45.1" 711 | source = "registry+https://github.com/rust-lang/crates.io-index" 712 | checksum = "5c573471f125075647d03df72e026074b7203790d41351cd6edc96f46bcccd36" 713 | 714 | [[package]] 715 | name = "zstd" 716 | version = "0.12.4" 717 | source = "registry+https://github.com/rust-lang/crates.io-index" 718 | checksum = "1a27595e173641171fc74a1232b7b1c7a7cb6e18222c11e9dfb9888fa424c53c" 719 | dependencies = [ 720 | "zstd-safe", 721 | ] 722 | 723 | [[package]] 724 | name = "zstd-safe" 725 | version = "6.0.6" 726 | source = "registry+https://github.com/rust-lang/crates.io-index" 727 | checksum = "ee98ffd0b48ee95e6c5168188e44a54550b1564d9d530ee21d5f0eaed1069581" 728 | dependencies = [ 729 | "libc", 730 | "zstd-sys", 731 | ] 732 | 733 | [[package]] 734 | name = "zstd-sys" 735 | version = "2.0.16+zstd.1.5.7" 736 | source = "registry+https://github.com/rust-lang/crates.io-index" 737 | checksum = "91e19ebc2adc8f83e43039e79776e3fda8ca919132d68a1fed6a5faca2683748" 738 | dependencies = [ 739 | "cc", 740 | "pkg-config", 741 | ] 742 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------