iso4217: remove obsolete ZWL (932)

update_version.php: use `err_exit()`
This commit is contained in:
gitlost 2025-02-01 18:14:48 +00:00
parent 21ed7b48dd
commit 8bd8802d44
4 changed files with 41 additions and 38 deletions

View file

@ -3,7 +3,7 @@
*/
/*
libzint - the open source barcode library
Copyright (C) 2021-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2021-2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -52,7 +52,7 @@ static int iso4217_numeric(int cc) {
0x45, 0x00, 0x00, 0x01, 0x00, 0x10, 0x11, 0x11,
0x00, 0x11, 0x11, 0x00, 0x81, 0x00, 0x04, 0x04,
0x04, 0x01, 0x00, 0x14, 0x00, 0x00, 0x44, 0x00,
0x20, 0x00, 0x00, 0xB0, 0x7F, 0xB5, 0xFD, 0xFB,
0x20, 0x00, 0x00, 0xB0, 0x6F, 0xB5, 0xFD, 0xFB,
0xBF, 0xBF, 0x3F, 0x47, 0xA4,
};
int b = cc >> 3;

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2021-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2021-2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -358,7 +358,7 @@ static void test_numeric(const testCtx *const p_ctx) {
/*315*/ { 929, 1 },
/*316*/ { 930, 1 },
/*317*/ { 931, 1 },
/*318*/ { 932, 1 }, /* TODO: 1 -> 0, 1 Sept 2024 */
/*318*/ { 932, 0 },
/*319*/ { 933, 1 },
/*320*/ { 934, 1 },
/*321*/ { 935, 0 },
@ -461,8 +461,7 @@ static int bc_iso4217_numeric(int cc) {
/*SGD*/ 702, /*VND*/ 704, /*SOS*/ 706, /*ZAR*/ 710, /*SSP*/ 728, /*SZL*/ 748, /*SEK*/ 752, /*CHF*/ 756, /*SYP*/ 760, /*THB*/ 764,
/*TOP*/ 776, /*TTD*/ 780, /*AED*/ 784, /*TND*/ 788, /*UGX*/ 800, /*MKD*/ 807, /*EGP*/ 818, /*GBP*/ 826, /*TZS*/ 834, /*USD*/ 840,
/*UYU*/ 858, /*UZS*/ 860, /*WST*/ 882, /*YER*/ 886, /*TWD*/ 901, /*ZWG*/ 924, /*SLE*/ 925, /*UYW*/ 927, /*VES*/ 928, /*MRU*/ 929,
/*STN*/ 930, /*CUC*/ 931, /*ZWL*/ 932, /* TODO: remove 1 Sept 2024 */
/*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944,
/*STN*/ 930, /*CUC*/ 931, /*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944,
/*RON*/ 946, /*CHE*/ 947, /*CHW*/ 948, /*TRY*/ 949, /*XAF*/ 950, /*XCD*/ 951, /*XOF*/ 952, /*XPF*/ 953, /*XBA*/ 955, /*XBB*/ 956,
/*XBC*/ 957, /*XBD*/ 958, /*XAU*/ 959, /*XDR*/ 960, /*XAG*/ 961, /*XPT*/ 962, /*XTS*/ 963, /*XPD*/ 964, /*XUA*/ 965, /*ZMW*/ 967,
/*SRD*/ 968, /*MGA*/ 969, /*COU*/ 970, /*AFN*/ 971, /*TJS*/ 972, /*AOA*/ 973, /*BGN*/ 975, /*CDF*/ 976, /*BAM*/ 977, /*EUR*/ 978,

View file

@ -2,7 +2,7 @@
/* Generate ISO 4217 include "backend/iso4217.h" for "backend/gs1.c" */
/*
libzint - the open source barcode library
Copyright (C) 2021-2024 <rstuart114@gmail.com>
Copyright (C) 2021-2025 <rstuart114@gmail.com>
*/
/* SPDX-License-Identifier: BSD-3-Clause */
@ -35,8 +35,7 @@ $numeric = array(
/*SGD*/ 702, /*VND*/ 704, /*SOS*/ 706, /*ZAR*/ 710, /*SSP*/ 728, /*SZL*/ 748, /*SEK*/ 752, /*CHF*/ 756, /*SYP*/ 760, /*THB*/ 764,
/*TOP*/ 776, /*TTD*/ 780, /*AED*/ 784, /*TND*/ 788, /*UGX*/ 800, /*MKD*/ 807, /*EGP*/ 818, /*GBP*/ 826, /*TZS*/ 834, /*USD*/ 840,
/*UYU*/ 858, /*UZS*/ 860, /*WST*/ 882, /*YER*/ 886, /*TWD*/ 901, /*ZWG*/ 924, /*SLE*/ 925, /*UYW*/ 927, /*VES*/ 928, /*MRU*/ 929,
/*STN*/ 930, /*CUC*/ 931, /*ZWL*/ 932, /* TODO: remove 1 Sept 2024 */
/*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944,
/*STN*/ 930, /*CUC*/ 931, /*BYN*/ 933, /*TMT*/ 934, /*GHS*/ 936, /*SDG*/ 938, /*UYI*/ 940, /*RSD*/ 941, /*MZN*/ 943, /*AZN*/ 944,
/*RON*/ 946, /*CHE*/ 947, /*CHW*/ 948, /*TRY*/ 949, /*XAF*/ 950, /*XCD*/ 951, /*XOF*/ 952, /*XPF*/ 953, /*XBA*/ 955, /*XBB*/ 956,
/*XBC*/ 957, /*XBD*/ 958, /*XAU*/ 959, /*XDR*/ 960, /*XAG*/ 961, /*XPT*/ 962, /*XTS*/ 963, /*XPD*/ 964, /*XUA*/ 965, /*ZMW*/ 967,
/*SRD*/ 968, /*MGA*/ 969, /*COU*/ 970, /*AFN*/ 971, /*TJS*/ 972, /*AOA*/ 973, /*BGN*/ 975, /*CDF*/ 976, /*BAM*/ 977, /*EUR*/ 978,
@ -70,7 +69,7 @@ if ($print_copyright) {
print <<<'EOD'
/*
libzint - the open source barcode library
Copyright (C) 2021-2024 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2021-2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions

View file

@ -56,12 +56,18 @@ $rc_str2 = "$major.$minor.$release.$build";
$year = date("Y");
/* `$to_do` is no. of lines that should get replaced/changed, not no. of replacements */
function version_replace($to_do, $file, $match_pattern, $replace_pattern, $replace_str) {
/* Ouput error message and exit */
function err_exit($line_no, $msg) {
global $basename;
exit("$basename:$line_no ERROR: $msg" . PHP_EOL);
}
/* `$to_do` is no. of lines that should get replaced/changed, not no. of replacements */
function version_replace($to_do, $file, $match_pattern, $replace_pattern, $replace_str) {
if (($get = file_get_contents($file)) === false) {
exit("$basename: ERROR: Could not read file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not read file \"$file\"");
}
$lines = explode("\n", $get);
@ -71,7 +77,7 @@ function version_replace($to_do, $file, $match_pattern, $replace_pattern, $repla
$cnt = 0;
$lines[$li] = preg_replace($replace_pattern, $replace_str, $line, -1, $cnt);
if ($cnt === 0 || $lines[$li] === NULL) {
exit("$basename: ERROR: Could not replace \"$match_pattern\" in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not replace \"$match_pattern\" in file \"$file\"");
}
$done++;
}
@ -80,18 +86,18 @@ function version_replace($to_do, $file, $match_pattern, $replace_pattern, $repla
}
}
if ($done !== $to_do) {
exit("$basename: ERROR: Only did $done replacements of $to_do in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Only did $done replacements of $to_do in file \"$file\"");
}
if (!file_put_contents($file, implode("\n", $lines))) {
exit("$basename: ERROR: Could not write file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not write file \"$file\"");
}
}
/* Do ".rc" replace, `$rc_str1` is comma-separated version, `$rc_str2` dot-separated version */
function rc_replace($file, $rc_str1, $rc_str2, $year = '') {
global $basename;
if (($get = file_get_contents($file)) === false) {
exit("$basename: ERROR: Could not read file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not read file \"$file\"");
}
$match_pattern1 = '/#define[ \t]+VER_FILEVERSION[ \t]+/';
@ -103,14 +109,14 @@ function rc_replace($file, $rc_str1, $rc_str2, $year = '') {
$cnt = 0;
$lines[$li] = preg_replace('/[0-9,]+/', $rc_str1, $line, 1, $cnt);
if ($cnt === 0 || $lines[$li] === NULL) {
exit("$basename: ERROR: Could not replace \"$match_pattern1\" in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not replace \"$match_pattern1\" in file \"$file\"");
}
$done++;
} else if (preg_match($match_pattern2, $line)) {
$cnt = 0;
$lines[$li] = preg_replace('/[0-9.]+/', $rc_str2, $line, 1, $cnt);
if ($cnt === 0 || $lines[$li] === NULL) {
exit("$basename: ERROR: Could not replace \"$match_pattern2\" in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not replace \"$match_pattern2\" in file \"$file\"");
}
$done++;
}
@ -119,7 +125,7 @@ function rc_replace($file, $rc_str1, $rc_str2, $year = '') {
}
}
if ($done !== 2) {
exit("$basename: ERROR: Only did $done replacements of 2 in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Only did $done replacements of 2 in file \"$file\"");
}
if ($year !== '') {
$match_pattern = '/VALUE[ \t]+"LegalCopyright",[ \t]+"Copyright /';
@ -129,26 +135,25 @@ function rc_replace($file, $rc_str1, $rc_str2, $year = '') {
$cnt = 0;
$lines[$li] = preg_replace('/[0-9]+/', $year, $line, 1, $cnt);
if ($cnt === 0 || $lines[$li] === NULL) {
exit("$basename: ERROR: Could not replace \"$match_pattern\" in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not replace \"$match_pattern\" in file \"$file\"");
}
$done++;
break;
}
}
if ($done !== 1) {
exit("$basename: ERROR: Failed to replace Copyright year in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Failed to replace Copyright year in file \"$file\"");
}
}
if (!file_put_contents($file, implode("\n", $lines))) {
exit("$basename: ERROR: Could not write file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not write file \"$file\"");
}
}
function year_replace($file, $year) {
global $basename;
if (($get = file_get_contents($file)) === false) {
exit("$basename: ERROR: Could not read file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not read file \"$file\"");
}
$match_pattern = '/Copyright /';
@ -159,17 +164,17 @@ function year_replace($file, $year) {
$cnt = 0;
$lines[$li] = preg_replace('/[0-9]+/', $year, $line, 1, $cnt);
if ($cnt === 0 || $lines[$li] === NULL) {
exit("$basename: ERROR: Could not replace \"$match_pattern\" in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not replace \"$match_pattern\" in file \"$file\"");
}
$done++;
break;
}
}
if ($done !== 1) {
exit("$basename: ERROR: Failed to replace Copyright year in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Failed to replace Copyright year in file \"$file\"");
}
if (!file_put_contents($file, implode("\n", $lines))) {
exit("$basename: ERROR: Could not write file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not write file \"$file\"");
}
}
@ -178,7 +183,7 @@ function year_replace($file, $year) {
$file = $data_dirname . 'CMakeLists.txt';
if (($get = file_get_contents($file)) === false) {
exit("$basename: ERROR: Could not read file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not read file \"$file\"");
}
$lines = explode("\n", $get);
@ -189,7 +194,7 @@ foreach ($lines as $li => $line) {
$mmr = $matches[1] === "MAJOR" ? $major : ($matches[1] === "MINOR" ? $minor : ($matches[1] === "RELEASE" ? $release : $build));
$lines[$li] = preg_replace('/[0-9]+\)/', $mmr . ')', $line, 1, $cnt);
if ($cnt === 0 || $lines[$li] === NULL) {
exit("$basename: ERROR: Could not replace ZINT_VERSION_{$matches[1]} in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not replace ZINT_VERSION_{$matches[1]} in file \"$file\"");
}
$done++;
}
@ -198,10 +203,10 @@ foreach ($lines as $li => $line) {
}
}
if ($done !== 4) {
exit("$basename: ERROR: Only did $done replacements of 4 in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Only did $done replacements of 4 in file \"$file\"");
}
if (!file_put_contents($file, implode("\n", $lines))) {
exit("$basename: ERROR: Could not write file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not write file \"$file\"");
}
// README
@ -233,7 +238,7 @@ version_replace(1, $data_dirname . 'backend/zint.h', '/^ \* Version: /', '/[0-9]
$file = $data_dirname . 'backend/zintconfig.h';
if (($get = file_get_contents($file)) === false) {
exit("$basename: ERROR: Could not read file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not read file \"$file\"");
}
$lines = explode("\n", $get);
@ -244,14 +249,14 @@ foreach ($lines as $li => $line) {
$mmr = $matches[1] === "MAJOR" ? $major : ($matches[1] === "MINOR" ? $minor : $release);
$lines[$li] = preg_replace('/[0-9]+/', $mmr, $line, 1, $cnt);
if ($cnt === 0 || $lines[$li] === NULL) {
exit("$basename: ERROR: Could not replace ZINT_VERSION_{$matches[1]} in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not replace ZINT_VERSION_{$matches[1]} in file \"$file\"");
}
$done++;
} elseif (preg_match('/define[ \t]+ZINT_VERSION_BUILD[ \t]+/', $line)) {
$cnt = 0;
$lines[$li] = preg_replace('/(BUILD[ \t]+)[0-9]+/', '${1}' . $build, $line, 1, $cnt);
if ($cnt === 0 || $lines[$li] === NULL) {
exit("$basename: ERROR: Could not replace ZINT_VERSION_BUILD in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not replace ZINT_VERSION_BUILD in file \"$file\"");
}
$done++;
}
@ -260,10 +265,10 @@ foreach ($lines as $li => $line) {
}
}
if ($done !== 4) {
exit("$basename: ERROR: Only did $done replacements of 4 in file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Only did $done replacements of 4 in file \"$file\"");
}
if (!file_put_contents($file, implode("\n", $lines))) {
exit("$basename: ERROR: Could not write file \"$file\"" . PHP_EOL);
err_exit(__LINE__, "Could not write file \"$file\"");
}
// backend/Makefile.mingw