mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 21:14:01 +01:00
raspberry_pi_nextcloud.sh 1276 -> 163, root_bl9000.sh 1116 -> 211, lookup_docs.sh 942 -> 165. Sixteen new libs. lookup_python was one 300-line function; its keyword-to-anchor mapping became python_keyword_doc, emitting result and desc tab-separated so the caller keeps its control flow. bl9000_mtkclient had cd X; work; cd - with three return paths. install_mtkclient became a subshell; extract_boot_with_mtkclient could not, since it exports BOOT_IMG - so the venv check moved before the cd, the cd is guarded, and the restores use a saved $PWD. Four more unguarded cd calls fixed, and a third instance of the lib chaining bug flattened. lookup_docs.sh had no SCRIPT_DIR at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
94 lines
3.1 KiB
Bash
Executable File
94 lines
3.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# C++ documentation lookup.
|
|
#
|
|
# Sourced by lookup_docs.sh; split out to keep it under the 250-line
|
|
# cap. Sourced rather than run, so it inherits the caller's strict mode
|
|
# and the variables defined above the source line.
|
|
|
|
#==============================================================================
|
|
# C/C++ specific lookup
|
|
#==============================================================================
|
|
lookup_cpp() {
|
|
local term="$1"
|
|
local doc_dir="$DOCS_DIR/c_cpp"
|
|
local result=""
|
|
local desc=""
|
|
|
|
# Resolve symlink if present (system package installs to c_cpp/system/)
|
|
[ -L "$doc_dir/system" ] && doc_dir="$doc_dir/system"
|
|
|
|
# Common C headers
|
|
case "$term" in
|
|
stdio.h | stdio)
|
|
[ -f "$doc_dir/reference/cstdio/index.html" ] && result="$doc_dir/reference/cstdio/index.html"
|
|
[ -f "$doc_dir/en/c/io.html" ] && result="$doc_dir/en/c/io.html"
|
|
desc="C standard I/O header"
|
|
;;
|
|
stdlib.h | stdlib)
|
|
[ -f "$doc_dir/reference/cstdlib/index.html" ] && result="$doc_dir/reference/cstdlib/index.html"
|
|
[ -f "$doc_dir/en/c/memory.html" ] && result="$doc_dir/en/c/memory.html"
|
|
desc="C standard library header"
|
|
;;
|
|
string.h | cstring)
|
|
[ -f "$doc_dir/reference/cstring/index.html" ] && result="$doc_dir/reference/cstring/index.html"
|
|
desc="C string handling header"
|
|
;;
|
|
math.h | cmath)
|
|
[ -f "$doc_dir/reference/cmath/index.html" ] && result="$doc_dir/reference/cmath/index.html"
|
|
desc="C math header"
|
|
;;
|
|
esac
|
|
|
|
# C++ STL containers
|
|
case "$term" in
|
|
vector)
|
|
[ -f "$doc_dir/reference/vector/index.html" ] && result="$doc_dir/reference/vector/index.html"
|
|
[ -f "$doc_dir/en/cpp/container/vector.html" ] && result="$doc_dir/en/cpp/container/vector.html"
|
|
desc="C++ std::vector container"
|
|
;;
|
|
map)
|
|
[ -f "$doc_dir/reference/map/index.html" ] && result="$doc_dir/reference/map/index.html"
|
|
desc="C++ std::map container"
|
|
;;
|
|
string)
|
|
[ -f "$doc_dir/reference/string/index.html" ] && result="$doc_dir/reference/string/index.html"
|
|
desc="C++ std::string"
|
|
;;
|
|
iostream)
|
|
[ -f "$doc_dir/reference/iostream/index.html" ] && result="$doc_dir/reference/iostream/index.html"
|
|
desc="C++ iostream header"
|
|
;;
|
|
esac
|
|
|
|
# C keywords
|
|
case "$term" in
|
|
if | else | for | while | do | switch | case | break | continue | return | goto)
|
|
[ -f "$doc_dir/en/c/language/$term.html" ] && result="$doc_dir/en/c/language/$term.html"
|
|
[ -f "$doc_dir/en/cpp/language/$term.html" ] && result="$doc_dir/en/cpp/language/$term.html"
|
|
desc="C/C++ keyword: $term"
|
|
;;
|
|
int | char | float | double | void | long | short | unsigned | signed)
|
|
[ -f "$doc_dir/en/c/language/type.html" ] && result="$doc_dir/en/c/language/type.html"
|
|
desc="C/C++ type: $term"
|
|
;;
|
|
struct | union | enum | typedef)
|
|
[ -f "$doc_dir/en/c/language/$term.html" ] && result="$doc_dir/en/c/language/$term.html"
|
|
desc="C/C++ keyword: $term"
|
|
;;
|
|
esac
|
|
|
|
# Search in files if not found (use -L to follow symlinks)
|
|
if [ -z "$result" ]; then
|
|
local found
|
|
found=$(find -L "$doc_dir" -name "*${term}*" -type f 2>/dev/null | head -1)
|
|
if [ -n "$found" ]; then
|
|
result="$found"
|
|
desc="C/C++: $term"
|
|
fi
|
|
fi
|
|
|
|
if [ -n "$result" ]; then
|
|
echo "$result|$desc"
|
|
fi
|
|
}
|