Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
  • Loading branch information
leleliu008 committed May 17, 2024
1 parent 0899e9e commit 8c652f6
Show file tree
Hide file tree
Showing 21 changed files with 67 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/alpinelinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: alpinelinux

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
alpinelinux:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/archlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: archlinux

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
archlinux:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/centos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CentOS Linux

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
centos8:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codacy-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: codacy-analysis

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
codacy-analysis:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Debian GNU/Linux

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Fedora

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: FreeBSD

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
freebsd:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gentoo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: gentoo

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
gentoo:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linuxmint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: LinuxMint

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: macos

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/manjaro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Manjaro Linux

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
test:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/netbsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: NetBSD

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
netbsd:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/openbsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: OpenBSD

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
openbsd:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/opensuse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: openSUSE

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
opensuse:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ppkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: ppkg

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
ppkg:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: 0.15.2
ref: 0.15.3

- id: check-if-has-new-commit
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: ubuntu

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
vcpkg:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: valgrind

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
valgrind:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/voidlinux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: voidlinux

on:
push:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]
pull_request:
branches: [ 0.15.2 ]
branches: [ 0.15.3 ]

jobs:
voidlinux:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.0)

project(uppm C)

set(PROJECT_VERSION 0.15.2)
set(PROJECT_VERSION 0.15.3)
set(PROJECT_VERSION_MAJOR 0)
set(PROJECT_VERSION_MINOR 15)
set(PROJECT_VERSION_PATCH 2)
set(PROJECT_VERSION_PATCH 3)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
Expand Down
38 changes: 28 additions & 10 deletions src/core/tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ int tar_list(const char * inputFilePath, int flags) {

finalize:
if (ret != ARCHIVE_OK) {
fprintf(stdout, "%s\n", archive_error_string(ar));
const char * errorMessage = archive_error_string(ar);

if (errorMessage == NULL || errorMessage[0] == '\0') {
fprintf(stderr, "unknown error.\n");
} else {
fprintf(stderr, "%s\n", errorMessage);
}
}

archive_read_close(ar);
Expand Down Expand Up @@ -97,11 +103,9 @@ int tar_extract(const char * outputDir, const char * inputFilePath, int flags, b
const char * entry_pathname = archive_entry_pathname(entry);

if (stripComponentsNumber > 0U) {
size_t entry_pathname_length = strlen(entry_pathname);

for (size_t i = 0; i < entry_pathname_length; i++) {
for (size_t i = 0; entry_pathname[i] != '\0'; i++) {
if (entry_pathname[i] == '/') {
entry_pathname = entry_pathname + i + 1U;
entry_pathname += i + 1U;
break;
}
}
Expand Down Expand Up @@ -131,10 +135,9 @@ int tar_extract(const char * outputDir, const char * inputFilePath, int flags, b

if (hardlinkname != NULL) {
if (stripComponentsNumber > 0U) {
size_t hardlinkname_length = strlen(hardlinkname);
for (size_t i = 0; i < hardlinkname_length; i++) {
for (size_t i = 0; hardlinkname[i] != '\0'; i++) {
if (hardlinkname[i] == '/') {
hardlinkname = hardlinkname + i + 1U;
hardlinkname += i + 1U;
break;
}
}
Expand Down Expand Up @@ -194,7 +197,15 @@ int tar_extract(const char * outputDir, const char * inputFilePath, int flags, b

finalize:
if (ret != ARCHIVE_OK) {
fprintf(stdout, "%s\n", archive_error_string(ar));
const char * errorMessage = archive_error_string(ar);

if (errorMessage == NULL || errorMessage[0] == '\0') {
fprintf(stderr, "unknown error.\n");
} else {
fprintf(stderr, "%s\n", errorMessage);
}

fprintf(stderr, "%s\n", errorMessage);
}

archive_read_close(ar);
Expand Down Expand Up @@ -427,7 +438,14 @@ int tar_create(const char * inputDir, const char * outputFilePath, ArchiveType t

finalize:
if (ret != ARCHIVE_OK) {
fprintf(stdout, "%s\n", archive_error_string(ar));
const char * errorMessage = archive_error_string(ar);

if (errorMessage == NULL || errorMessage[0] == '\0') {
fprintf(stderr, "unknown error.\n");
} else {
fprintf(stderr, "%s\n", errorMessage);
}

archive_read_close(ar);
archive_read_free(ar);
}
Expand Down

0 comments on commit 8c652f6

Please sign in to comment.