rss.c: some fixes for separators, allow check digit, refactoring; bwipp_dump.ps

This commit is contained in:
gitlost 2020-07-10 19:39:32 +01:00
parent 9768cd004a
commit c1fb51ba42
33 changed files with 4451 additions and 1360 deletions

View file

@ -135,18 +135,6 @@ INTERNAL int posn(const char set_string[], const char data) {
return -1;
}
/* Returns the number of times a character occurs in a string */
INTERNAL int ustrchr_cnt(const unsigned char string[], const size_t length, const unsigned char c) {
int count = 0;
unsigned int i;
for (i = 0; i < length; i++) {
if (string[i] == c) {
count++;
}
}
return count;
}
/* Return true (1) if a module is dark/black/colour, otherwise false (0) */
INTERNAL int module_is_set(const struct zint_symbol *symbol, const int y_coord, const int x_coord) {
if (symbol->symbology == BARCODE_ULTRA) {
@ -272,7 +260,7 @@ INTERNAL int istwodigits(const unsigned char source[], const int length, const i
}
/* State machine to decode UTF-8 to Unicode codepoints (state 0 means done, state 12 means error) */
INTERNAL unsigned int decode_utf8(unsigned int* state, unsigned int* codep, const unsigned char byte) {
INTERNAL unsigned int decode_utf8(unsigned int *state, unsigned int *codep, const unsigned char byte) {
/*
Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
@ -375,8 +363,9 @@ INTERNAL void set_minimum_height(struct zint_symbol *symbol, const int min_heigh
}
/* Calculate optimized encoding modes. Adapted from Project Nayuki */
INTERNAL void pn_define_mode(char* mode, const unsigned int data[], const size_t length, const int debug,
unsigned int state[], const char mode_types[], const int num_modes, pn_head_costs head_costs, pn_switch_cost switch_cost, pn_eod_cost eod_cost, pn_cur_cost cur_cost) {
INTERNAL void pn_define_mode(char *mode, const unsigned int data[], const size_t length, const int debug,
unsigned int state[], const char mode_types[], const int num_modes,
pn_head_costs head_costs, pn_switch_cost switch_cost, pn_eod_cost eod_cost, pn_cur_cost cur_cost) {
/*
* Copyright (c) Project Nayuki. (MIT License)
* https://www.nayuki.io/page/qr-code-generator-library
@ -398,12 +387,12 @@ INTERNAL void pn_define_mode(char* mode, const unsigned int data[], const size_t
char char_modes[length * num_modes];
unsigned int cur_costs[num_modes];
#else
unsigned int* prev_costs;
char* char_modes;
unsigned int* cur_costs;
prev_costs = (unsigned int*) _alloca(num_modes * sizeof(unsigned int));
char_modes = (char*) _alloca(length * num_modes);
cur_costs = (unsigned int*) _alloca(num_modes * sizeof(unsigned int));
unsigned int *prev_costs;
char *char_modes;
unsigned int *cur_costs;
prev_costs = (unsigned int *) _alloca(num_modes * sizeof(unsigned int));
char_modes = (char *) _alloca(length * num_modes);
cur_costs = (unsigned int *) _alloca(num_modes * sizeof(unsigned int));
#endif
/* char_modes[i * num_modes + j] represents the mode to encode the code point at index i such that the final
@ -462,13 +451,13 @@ INTERNAL void pn_define_mode(char* mode, const unsigned int data[], const size_t
}
if (debug & ZINT_DEBUG_PRINT) {
printf(" Mode: %.*s\n", (int)length, mode);
printf(" Mode: %.*s\n", (int) length, mode);
}
}
#ifdef ZINT_TEST
/* Dumps hex-formatted codewords in symbol->errtxt (for use in testing) */
void debug_test_codeword_dump(struct zint_symbol *symbol, unsigned char* codewords, int length) {
void debug_test_codeword_dump(struct zint_symbol *symbol, unsigned char *codewords, int length) {
int i, max = length, cnt_len = 0;
if (length > 30) { /* 30*3 < errtxt 92 (100 - "Warning ") chars */
sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */
@ -481,7 +470,7 @@ void debug_test_codeword_dump(struct zint_symbol *symbol, unsigned char* codewor
symbol->errtxt[strlen(symbol->errtxt) - 1] = '\0'; /* Zap last space */
}
void debug_test_codeword_dump_int(struct zint_symbol *symbol, int* codewords, int length) {
void debug_test_codeword_dump_int(struct zint_symbol *symbol, int *codewords, int length) {
int i, max = 0, cnt_len, errtxt_len;
char temp[20];
errtxt_len = sprintf(symbol->errtxt, "(%d) ", length); /* Place the number of codewords at the front */