Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions ext/iec16022ecc200.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,13 +778,12 @@ encmake (int l, unsigned char *s, int *lenp, char exact)
return encoding;
}

void iec16022init(int *Wptr, int *Hptr, const char *barcode)
void iec16022init(int *Wptr, int *Hptr, int barcode_length)
{
if(Wptr == NULL || Hptr == NULL || barcode == NULL) return;
if(Wptr == NULL || Hptr == NULL) return;

int barcodelen = strlen(barcode) + 1;
struct ecc200matrix_s *matrix;
for (matrix = ecc200matrix; matrix->bytes < barcodelen; matrix++);
for (matrix = ecc200matrix; matrix->bytes <= barcode_length; matrix++);
*Wptr = matrix->W;
*Hptr = matrix->H;
}
Expand Down
17 changes: 4 additions & 13 deletions ext/semacode.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ structure is consulted for any operations, such as to get the
semacode dimensions. It deallocates any previous data before
generating a new encoding.

Due to a bug in the underlying encoder, we do two things

* append a space character before encoding, to get around
an off by one error lurking in the C code

* manually select the best barcode dimensions, to avoid
an encoder bug where sometimes no suitable encoding would
be found
Due to a bug in the underlying encoder, we manually select the best barcode
dimensions to avoid an encoder bug where sometimes no suitable encoding
would be found

*/
semacode_t*
Expand All @@ -53,12 +48,8 @@ encode_string(semacode_t *semacode, int message_length, char *message)

bzero(semacode, sizeof(semacode_t));

// work around encoding bug by appending an extra character.
strcat(message, " ");
message_length++;

// choose the best grid that will hold our message
iec16022init(&semacode->width, &semacode->height, message);
iec16022init(&semacode->width, &semacode->height, message_length);

// encode the actual data
semacode->data = (char *) iec16022ecc200(
Expand Down