[mchehab-zbar] Add new port (#16113)

* Add mchehab/zbar

* Quote all paths

Co-authored-by: Cheney Wang <38240633+Cheney-W@users.noreply.github.com>

* Update to 0.23.90

* Flip name

* Update version registry

Co-authored-by: Cheney Wang <38240633+Cheney-W@users.noreply.github.com>
This commit is contained in:
Ulysses1337 2022-08-24 17:08:34 +01:00 committed by GitHub
parent c350275db4
commit 55112eb54a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 284 additions and 27 deletions

View File

@ -0,0 +1,89 @@
diff --git a/zbar/symbol.c b/zbar/symbol.c
index 27dbc87..1059a72 100644
--- a/zbar/symbol.c
+++ b/zbar/symbol.c
@@ -100,40 +100,29 @@ const char *zbar_get_orientation_name (zbar_orientation_t orient)
int _zbar_get_symbol_hash (zbar_symbol_type_t sym)
{
- static const signed char hash[ZBAR_CODE128 + 1] = {
- [0 ... ZBAR_CODE128] = -1,
-
- /* [ZBAR_FOO] = 0, is empty */
- [ZBAR_SQCODE] = 1,
- [ZBAR_CODE128] = 2,
- [ZBAR_EAN13] = 3,
- [ZBAR_UPCA] = 4,
- [ZBAR_EAN8] = 5,
- [ZBAR_UPCE] = 6,
- [ZBAR_ISBN13] = 7,
- [ZBAR_ISBN10] = 8,
- [ZBAR_CODE39] = 9,
- [ZBAR_I25] = 10,
- [ZBAR_PDF417] = 11,
- [ZBAR_QRCODE] = 12,
- [ZBAR_DATABAR] = 13,
- [ZBAR_DATABAR_EXP] = 14,
- [ZBAR_CODE93] = 15,
- [ZBAR_EAN2] = 16,
- [ZBAR_EAN5] = 17,
- [ZBAR_COMPOSITE] = 18,
- [ZBAR_CODABAR] = 19,
-
- /* Please update NUM_SYMS accordingly */
- };
- int h;
-
- assert (sym >= ZBAR_PARTIAL && sym <= ZBAR_CODE128);
-
- h = hash[sym];
- assert (h >= 0 && h < NUM_SYMS);
-
- return h;
+ switch(sym)
+ {
+ default: return -1;
+ case ZBAR_SQCODE: return 1;
+ case ZBAR_CODE128: return 2;
+ case ZBAR_EAN13: return 3;
+ case ZBAR_UPCA: return 4;
+ case ZBAR_EAN8: return 5;
+ case ZBAR_UPCE: return 6;
+ case ZBAR_ISBN13: return 7;
+ case ZBAR_ISBN10: return 8;
+ case ZBAR_CODE39: return 9;
+ case ZBAR_I25: return 10;
+ case ZBAR_PDF417: return 11;
+ case ZBAR_QRCODE: return 12;
+ case ZBAR_DATABAR: return 13;
+ case ZBAR_DATABAR_EXP: return 14;
+ case ZBAR_CODE93: return 15;
+ case ZBAR_EAN2: return 16;
+ case ZBAR_EAN5: return 17;
+ case ZBAR_COMPOSITE: return 18;
+ case ZBAR_CODABAR: return 19;
+ }
}
void _zbar_symbol_free (zbar_symbol_t *sym)
diff --git a/zbar/window/win.c b/zbar/window/win.c
index b949f65..7edcfa2 100644
--- a/zbar/window/win.c
+++ b/zbar/window/win.c
@@ -194,7 +194,7 @@ int _zbar_window_draw_polygon (zbar_window_t *w,
win_set_rgb(hdc, rgb);
point_t org = w->scaled_offset;
- POINT gdipts[npts + 1];
+ POINT* gdipts = malloc((npts + 1) * sizeof(POINT));
int i;
for(i = 0; i < npts; i++) {
point_t p = window_scale_pt(w, pts[i]);
@@ -204,6 +204,7 @@ int _zbar_window_draw_polygon (zbar_window_t *w,
gdipts[npts] = gdipts[0];
Polyline(hdc, gdipts, npts + 1);
+ free(gdipts);
return(0);
}

View File

@ -0,0 +1,13 @@
diff --git a/zbar/decoder/databar.c b/zbar/decoder/databar.c
index 8cfa848..ffb972e 100644
--- a/zbar/decoder/databar.c
+++ b/zbar/decoder/databar.c
@@ -695,7 +695,7 @@ lookup_sequence (databar_segment_t *seg,
seq[i++] = s;
}
dbprintf(2, "}");
- seq[n] = -1;
+ if (n<22) {seq[n]=-1;} /* https://github.com/mchehab/zbar/issues/219 */
return(fixed < 1);
}

View File

@ -0,0 +1,48 @@
if(EXISTS ${CURRENT_INSTALLED_DIR}/share/zbar/copyright)
message(FATAL_ERROR "${PORT} conflicts with zbar. Please remove zbar before installing ${PORT}.")
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO mchehab/zbar
REF 0.23.90
SHA512 d73d71873bec68ee021997512a9edbd223f5f5fe43c66c4dd3502224ba6009be2e5e1714766cb8e1056244673e87e0939ed0319116f61d7371b5ab79fb5e04eb
HEAD_REF master
PATCHES
c99.patch
issue219.patch
windows.patch
x64.patch
)
vcpkg_configure_make(
SOURCE_PATH "${SOURCE_PATH}"
NO_ADDITIONAL_PATHS
ADD_BIN_TO_PATH
ADDITIONAL_MSYS_PACKAGES findutils gettext gettext-devel liblzma tar xz
OPTIONS
--disable-video
--without-gtk
--without-imagemagick
--without-java
--without-python
--without-qt
)
vcpkg_install_make()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/bin"
"${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/share/doc")
file(RENAME "${CURRENT_PACKAGES_DIR}/share/zbar" "${CURRENT_PACKAGES_DIR}/share/${PORT}")
configure_file("${SOURCE_PATH}/COPYING" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY)

View File

@ -0,0 +1,11 @@
{
"name": "mchehab-zbar",
"version": "0.23.90",
"description": "ZBar is an open source software suite for reading bar codes from various sources, including webcams. This fork is actively maintained.",
"homepage": "https://github.com/mchehab/zbar",
"license": "LGPL-2.1-or-later",
"supports": "windows & !uwp",
"dependencies": [
"libiconv"
]
}

View File

@ -0,0 +1,68 @@
diff --git a/configure.ac b/configure.ac
index c8fea14..eb0a097 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,7 +55,7 @@ AC_DEFINE_UNQUOTED([LIB_VERSION_REVISION],
[Library revision])
AM_CPPFLAGS="-I\$(top_srcdir)/include"
-AM_CFLAGS="-Wall -Wno-parentheses"
+AM_CFLAGS="-Wall"
AM_CXXFLAGS="$AM_CFLAGS"
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CFLAGS])
diff --git a/zbar/Makefile.am b/zbar/Makefile.am
index ca54d01..6c0cd83 100644
--- a/zbar/Makefile.am
+++ b/zbar/Makefile.am
@@ -68,7 +68,7 @@ if WIN32
libzbar_la_SOURCES += processor/win.c libzbar.rc
libzbar_la_CPPFLAGS += -mthreads
-libzbar_la_LDFLAGS += -mthreads
+libzbar_la_LDFLAGS += -mthreads -Xcompiler -Wl,-DEBUG
# FIXME broken
libzbar_la_LIBADD += libzbar-rc.lo
else
diff --git a/zbar/libzbar.rc b/zbar/libzbar.rc
index 413635b..c241f82 100644
--- a/zbar/libzbar.rc
+++ b/zbar/libzbar.rc
@@ -17,8 +17,7 @@ VS_VERSION_INFO VERSIONINFO
VALUE "InternalName", "libzbar"
VALUE "OriginalFilename", "libzbar-" XSTR(LIB_VERSION_MAJOR) ".dll"
- VALUE "FileVersion", XSTR(LIB_VERSION_MAJOR) "." \
- XSTR(LIB_VERSION_MINOR) "." XSTR(LIB_VERSION_REVISION)
+ VALUE "FileVersion", XSTR(LIB_VERSION_MAJOR) "." XSTR(LIB_VERSION_MINOR) "." XSTR(LIB_VERSION_REVISION)
VALUE "ProductVersion", PACKAGE_VERSION
VALUE "FileDescription", "Bar code reader library"
diff --git a/zbar/processor.h b/zbar/processor.h
index d5e9fef..54d6584 100644
--- a/zbar/processor.h
+++ b/zbar/processor.h
@@ -27,7 +27,9 @@
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
-#include <unistd.h>
+#ifndef WIN32
+# include <unistd.h>
+#endif
#include <stdlib.h>
#include <string.h>
diff --git a/zbar/thread.h b/zbar/thread.h
index 96d6415..252d3f2 100644
--- a/zbar/thread.h
+++ b/zbar/thread.h
@@ -35,7 +35,7 @@
# define HAVE_THREADS
# define ZTHREAD DWORD WINAPI
-typedef ZTHREAD (zbar_thread_proc_t)(void*);
+typedef ZTHREAD zbar_thread_proc_t(void*);
typedef DWORD zbar_thread_id_t;

View File

@ -0,0 +1,21 @@
diff --git a/zbar/decoder.c b/zbar/decoder.c
index 7f7336f..e9ffc45 100644
--- a/zbar/decoder.c
+++ b/zbar/decoder.c
@@ -25,6 +25,7 @@
#include <stdlib.h> /* malloc, calloc, free */
#include <stdio.h> /* snprintf */
#include <string.h> /* memset, strlen */
+#include <stddef.h> /* offsetof */
#include <zbar.h>
@@ -113,7 +114,7 @@ void zbar_decoder_destroy (zbar_decoder_t *dcode)
void zbar_decoder_reset (zbar_decoder_t *dcode)
{
- memset(dcode, 0, (long)&dcode->buf_alloc - (long)dcode);
+ memset(dcode, 0, offsetof(zbar_decoder_t, buf_alloc));
#if ENABLE_EAN == 1
ean_reset(&dcode->ean);
#endif

View File

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
# Wrapper for windres to rc which do not understand '-i -o --output-format'. # Wrapper for windres to rc which do not understand '-i -o --output-format'.
# cvtres is invoked by the linker # cvtres is invoked by the linker
scriptversion=2021-04-02.18; # UTC scriptversion=2022-08-24.12; # UTC
nl=' nl='
@ -59,67 +59,61 @@ func_file_conv ()
func_windres_wrapper () func_windres_wrapper ()
{ {
# Assume a capable shell # Assume a capable shell
bin=
in= in=
out= out=
for arg for arg
do do
if test -n "$eat"; then if test -z "$bin"; then
bin=$1
elif test -n "$eat"; then
eat= eat=
else else
case $1 in case $1 in
--output-format=*)
;;
--define*) --define*)
eat=1 eat=1
set x "$@" "-d $2" set -- "$@" "-d $2"
shift
;; ;;
--include-dir*) --include-dir*)
eat=1 eat=1
func_file_conv "$2" func_file_conv "$2"
set x "$@" "-I $file" set -- "$@" "-I $file"
shift
;; ;;
-o) -o)
eat=1 eat=1
func_file_conv "$2" func_file_conv "$2"
out="$file" out="$file"
echo "OUTPUT:$file" echo "OUTPUT:$file"
set x "$@"
shift
;; ;;
*.obj) *.obj)
func_file_conv "$1" func_file_conv "$1"
out="$file" out="$file"
echo "OUTPUT:$file" echo "OUTPUT:$file"
set x "$@"
shift
;;
--output-format=*)
set x "$@"
shift
;; ;;
-i) -i)
eat=1 eat=1
func_file_conv "$2" mingw func_file_conv "$2" mingw
in="$file" in="$file"
echo "INPUT:$file" echo "INPUT:$file"
set x "$@"
shift
;; ;;
-*) -*)
set x "$@" "${1//\\\"/\"}" set -- "$@" "${1//\\\"/\"}"
shift
;; ;;
*) *)
set x "$@" "$1" # libtool reorders arguments; save unqualified one as input
shift func_file_conv "$1"
in="$file"
echo "INPUT:$file"
;; ;;
esac esac
fi fi
shift shift
done done
echo "$@" -fo "$out" "$in" echo "$bin" "$@" -fo "$out" "$in"
exec "$@" -fo "$out" "$in" exec "$bin" "$@" -fo "$out" "$in"
exit 1 exit 1
} }

View File

@ -4552,6 +4552,10 @@
"baseline": "2.28.1", "baseline": "2.28.1",
"port-version": 0 "port-version": 0
}, },
"mchehab-zbar": {
"baseline": "0.23.90",
"port-version": 0
},
"mcpp": { "mcpp": {
"baseline": "2.7.2.14", "baseline": "2.7.2.14",
"port-version": 3 "port-version": 3

View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "7c066057a5c24bbea65e26e9e7519db938a2932e",
"version": "0.23.90",
"port-version": 0
}
]
}