Added fix for enca to exit 1 each time it prints 'unknown' #19.#76
Merged
Merged
Conversation
Syed-Shahrukh-OSSRevival
commented
Jun 4, 2025
Member
- Updated the function return type which printed the unknown, so it return error in case of unknown.
- Added cover for edge cases of error.
Collaborator
|
Shouldn't the |
Member
Author
|
This is the implementation of enca_charset_is_known which checks if the charset is know or not. enca.h:139 #define enca_charset_is_known(cs) \
((cs) != ENCA_CS_UNKNOWN)With the -m flag the charset is searched within CHARSET_INFO array by the function enca_charset_name encnames.c:137 The data structure that is used by the array is defined in internal.h:77 struct _EncaCharsetInfo {
int enca;
int rfc1345;
int cstocs;
int iconv;
int mime;
const char *human;
unsigned int flags;
unsigned int nsurface;
};encoding.h:3 EncaCharsetInfo CHARSET_INFO[] =For the charset this is the array entry. The value of mime is -1. {
148, 150, -1, 149, -1,
"Macintosh Cyrillic",
ENCA_CHARSET_8BIT | ENCA_CHARSET_FIXED | ENCA_CHARSET_REGULAR,
ENCA_SURFACE_EOL_CR
}Using the array data function enca_charset_name case OTYPE_MIME:
if (enca_charset_name(result.charset, ENCA_NAME_STYLE_MIME) != NULL)
puts(enca_charset_name(result.charset, ENCA_NAME_STYLE_MIME));
else {
puts(enca_charset_name(ENCA_CS_UNKNOWN, ENCA_NAME_STYLE_MIME));
res = ERR_CANNOT;
}The function returns NULL at case ENCA_NAME_STYLE_MIME:
return cs->mime < 0 ? NULL : ALIAS_LIST[cs->mime];So the else case is executed encnames.c:142 if (charset == ENCA_CS_UNKNOWN) {
switch (whatname) {
case ENCA_NAME_STYLE_RFC1345:
case ENCA_NAME_STYLE_ENCA:
case ENCA_NAME_STYLE_MIME:
return UNKNOWN_CHARSET_NAME;which prints unknown. So to ensure that this unknown is covered a return type is added to print_results. enca.c:215 |
Collaborator
|
Merged, thanks for your contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.