mirror of
https://github.com/xroche/httrack.git
synced 2026-06-16 23:33:18 +03:00
Compare commits
7 Commits
cleanup/ht
...
cleanup/ht
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b52b117b90 | ||
|
|
19d925e6e0 | ||
|
|
90847cf083 | ||
|
|
1611add5a9 | ||
|
|
92f4ea044b | ||
|
|
4344801983 | ||
|
|
25b9a53c89 |
58
.github/workflows/ci.yml
vendored
58
.github/workflows/ci.yml
vendored
@@ -320,20 +320,37 @@ jobs:
|
||||
lint:
|
||||
name: lint (shellcheck, shfmt)
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
SHFMT_VERSION: v3.8.0
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
# shfmt is a pinned release binary, so it never changes: cache it keyed on
|
||||
# the version. Same rationale as the git-clang-format driver below -- avoid
|
||||
# re-downloading an unchanging file from github.com on every run.
|
||||
- name: Cache shfmt binary
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/shfmt/shfmt
|
||||
key: shfmt-${{ env.SHFMT_VERSION }}-${{ runner.arch }}
|
||||
|
||||
- name: Install linters
|
||||
env:
|
||||
SHFMT_VERSION: v3.8.0
|
||||
run: |
|
||||
set -euo pipefail
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends shellcheck
|
||||
# shfmt is not packaged in apt; fetch a pinned release binary.
|
||||
curl -fsSL -o /tmp/shfmt \
|
||||
"https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_$(dpkg --print-architecture)"
|
||||
sudo install -m 0755 /tmp/shfmt /usr/local/bin/shfmt
|
||||
# shfmt is not packaged in apt; fetch a pinned release binary (cold
|
||||
# cache only), retrying through transient errors.
|
||||
shfmt="$HOME/.cache/shfmt/shfmt"
|
||||
if [ ! -s "$shfmt" ]; then
|
||||
echo "shfmt cache MISS: fetching ${SHFMT_VERSION} from github.com"
|
||||
mkdir -p "$(dirname "$shfmt")"
|
||||
curl --retry 5 --retry-all-errors -fsSL -o "$shfmt" \
|
||||
"https://github.com/mvdan/sh/releases/download/${SHFMT_VERSION}/shfmt_${SHFMT_VERSION}_linux_$(dpkg --print-architecture)"
|
||||
else
|
||||
echo "shfmt cache HIT: using cached ${SHFMT_VERSION}"
|
||||
fi
|
||||
sudo install -m 0755 "$shfmt" /usr/local/bin/shfmt
|
||||
|
||||
# Lint the scripts we maintain; the legacy scripts are a separate cleanup.
|
||||
- name: shellcheck
|
||||
@@ -349,11 +366,24 @@ jobs:
|
||||
name: format (clang-format-19, changed lines)
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
# Single-source the tag so the cache key and the fetch URL can never drift.
|
||||
LLVM_TAG: llvmorg-19.1.7
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# The git-clang-format driver is pinned to an immutable release tag, so the
|
||||
# fetched file never changes: cache it keyed on the tag. raw.githubusercontent.com
|
||||
# 429-rate-limits the shared runner egress IPs, and re-downloading an unchanging
|
||||
# file every run was the only thing that could (and did) hit that limit.
|
||||
- name: Cache git-clang-format driver
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.cache/git-clang-format/git-clang-format
|
||||
key: git-clang-format-${{ env.LLVM_TAG }}
|
||||
|
||||
- name: Install clang-format 19 (pinned, from apt.llvm.org)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -364,11 +394,17 @@ jobs:
|
||||
| sudo tee /etc/apt/sources.list.d/llvm-19.list >/dev/null
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends clang-format-19
|
||||
# git-clang-format driver, pinned to an immutable release tag (not a
|
||||
# moving branch) since we curl and then execute it.
|
||||
sudo curl -fsSL -o /usr/local/bin/git-clang-format \
|
||||
https://raw.githubusercontent.com/llvm/llvm-project/llvmorg-19.1.7/clang/tools/clang-format/git-clang-format
|
||||
sudo chmod 0755 /usr/local/bin/git-clang-format
|
||||
# Cold cache only: fetch the driver, retrying through transient 429s.
|
||||
driver="$HOME/.cache/git-clang-format/git-clang-format"
|
||||
if [ ! -s "$driver" ]; then
|
||||
echo "git-clang-format cache MISS: fetching ${LLVM_TAG} from raw.githubusercontent.com"
|
||||
mkdir -p "$(dirname "$driver")"
|
||||
curl --retry 5 --retry-all-errors -fsSL -o "$driver" \
|
||||
"https://raw.githubusercontent.com/llvm/llvm-project/${LLVM_TAG}/clang/tools/clang-format/git-clang-format"
|
||||
else
|
||||
echo "git-clang-format cache HIT: using cached ${LLVM_TAG}"
|
||||
fi
|
||||
sudo install -m 0755 "$driver" /usr/local/bin/git-clang-format
|
||||
clang-format-19 --version
|
||||
|
||||
- name: Check formatting of changed lines
|
||||
|
||||
@@ -129,7 +129,8 @@ HTS_UNUSED static int linputsoc_t(T_SOC soc, char *s, int max, int timeout);
|
||||
HTS_UNUSED static int linput(FILE * fp, char *s, int max);
|
||||
|
||||
/* Language files */
|
||||
HTS_UNUSED static int htslang_load(char *limit_to, const char *apppath);
|
||||
HTS_UNUSED static int htslang_load(char *limit_to, size_t limit_size,
|
||||
const char *apppath);
|
||||
HTS_UNUSED static void conv_printf(const char *from, char *to);
|
||||
HTS_UNUSED static void LANG_DELETE(void);
|
||||
HTS_UNUSED static void LANG_INIT(const char *path);
|
||||
@@ -325,7 +326,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
|
||||
/* Load strings */
|
||||
htslang_init();
|
||||
if (!htslang_load(NULL, path)) {
|
||||
if (!htslang_load(NULL, 0, path)) {
|
||||
fprintf(stderr, "unable to find lang.def and/or lang/ strings in %s\n",
|
||||
path);
|
||||
return 0;
|
||||
@@ -511,7 +512,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
char *s = buffer;
|
||||
char *e, *f;
|
||||
|
||||
strcatbuff(buffer, "&");
|
||||
strlcatbuff(buffer, "&", buffer_size);
|
||||
while(s && (e = strchr(s, '=')) && (f = strchr(s, '&'))) {
|
||||
const char *ua;
|
||||
String sua = STRING_EMPTY;
|
||||
@@ -935,7 +936,7 @@ int smallserver(T_SOC soc, char *url, char *method, char *data, char *path) {
|
||||
int listDefault = 0;
|
||||
|
||||
name[0] = '\0';
|
||||
strncatbuff(name, str, n);
|
||||
strlncatbuff(name, str, sizeof(name_), n);
|
||||
|
||||
if (strncmp(name, "/*", 2) == 0) {
|
||||
/* comments */
|
||||
@@ -1490,7 +1491,7 @@ int smallserver_setkeyarr(const char *key, int id, const char *key2, const char
|
||||
return coucal_write(NewLangList, tmp, (intptr_t) strdup(value));
|
||||
}
|
||||
|
||||
static int htslang_load(char *limit_to, const char *path) {
|
||||
static int htslang_load(char *limit_to, size_t limit_size, const char *path) {
|
||||
const char *hashname;
|
||||
char catbuff[CATBUFF_SIZE];
|
||||
|
||||
@@ -1545,7 +1546,7 @@ static int htslang_load(char *limit_to, const char *path) {
|
||||
char *const buff = (char *) malloc(len + 1);
|
||||
|
||||
if (buff) {
|
||||
strcpybuff(buff, intkey);
|
||||
strlcpybuff(buff, intkey, len + 1);
|
||||
coucal_add(NewLangStrKeys, key, (intptr_t) buff);
|
||||
}
|
||||
}
|
||||
@@ -1568,9 +1569,9 @@ static int htslang_load(char *limit_to, const char *path) {
|
||||
/* Get only language name */
|
||||
if (limit_to) {
|
||||
if (hashname)
|
||||
strcpybuff(limit_to, hashname);
|
||||
strlcpybuff(limit_to, hashname, limit_size);
|
||||
else
|
||||
strcpybuff(limit_to, "???");
|
||||
strlcpybuff(limit_to, "???", limit_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1750,7 +1751,7 @@ static void LANG_INIT(const char *path) {
|
||||
static int LANG_T(const char *path, int l) {
|
||||
if (l >= 0) {
|
||||
QLANG_T(l);
|
||||
htslang_load(NULL, path);
|
||||
htslang_load(NULL, 0, path);
|
||||
}
|
||||
return QLANG_T(-1); // 0=default (english)
|
||||
}
|
||||
@@ -1764,7 +1765,7 @@ static int LANG_SEARCH(const char *path, const char *iso) {
|
||||
do {
|
||||
QLANG_T(i);
|
||||
strcpybuff(lang_str, "LANGUAGE_ISO");
|
||||
htslang_load(lang_str, path);
|
||||
htslang_load(lang_str, sizeof(lang_str), path);
|
||||
if (strfield(iso, lang_str)) {
|
||||
found = i;
|
||||
}
|
||||
@@ -1783,10 +1784,10 @@ static int LANG_LIST(const char *path, char *buffer, size_t buffer_size) {
|
||||
do {
|
||||
QLANG_T(i);
|
||||
strlcpybuff(lang_str, "LANGUAGE_NAME", buffer_size);
|
||||
htslang_load(lang_str, path);
|
||||
htslang_load(lang_str, sizeof(lang_str), path);
|
||||
if (strlen(lang_str) > 0) {
|
||||
if (buffer[0])
|
||||
strcatbuff(buffer, "\n");
|
||||
strlcatbuff(buffer, "\n", buffer_size);
|
||||
strlcatbuff(buffer, lang_str, buffer_size);
|
||||
}
|
||||
i++;
|
||||
|
||||
Reference in New Issue
Block a user