Add a New Comment (Rich Markup)
Comment Type & Canned Response: None No canned response available
From cc47a7ed43f5b686027944e1f9ba31c30052695d Mon Sep 17 00:00:00 2001 From: Bjarni Ingi Gislason <bjarniig@vortex.is> Date: Mon, 29 Aug 2022 22:49:11 +0000 Subject: [PATCH] preconv.cpp: move conditional outside of the function "detect_file_encoding"
Patch is also in the attachment.
File: src/preproc/preconv/preconv.cpp
Compilation with "--config uchardet=no") shows a warning:
CXX src/preproc/preconv/preconv-preconv.o ../src/preproc/preconv/preconv.cpp: In function 'char* detect_file_encoding(FILE*)': ../src/preproc/preconv/preconv.cpp:1009:28: warning: unused parameter 'fp' [-Wunused-parameter] 1009 | detect_file_encoding(FILE *fp) | ~~~~~~^~
This function is only needed when the "uchardet" library is used, so the function should only be called in that case.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@vortex.is> --- src/preproc/preconv/preconv.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/src/preproc/preconv/preconv.cpp b/src/preproc/preconv/preconv.cpp index d707f765e..f8d2e416f 100644 --- a/src/preproc/preconv/preconv.cpp +++ b/src/preproc/preconv/preconv.cpp @@ -1005,10 +1005,14 @@ check_coding_tag(FILE *fp, string &data) return NULL; }
+#ifdef HAVE_UCHARDET + char * detect_file_encoding(FILE *fp) { +/* #ifdef HAVE_UCHARDET +*/ uchardet_t ud = NULL; struct stat stat_buf; size_t len, read_bytes; @@ -1070,10 +1074,10 @@ end: free(data);
return ret; -#else /* not HAVE_UCHARDET */ - return NULL; -#endif /* not HAVE_UCHARDET */ +//#else /* not HAVE_UCHARDET */ +// return NULL; } +#endif /* HAVE_UCHARDET */
// --------------------------------------------------------- // Handle an input file. If `filename` is "-", read the @@ -1140,8 +1144,13 @@ do_file(const char *filename) if (!file_encoding) { if (is_debugging) fprintf(stderr, " no coding tag\n"); - if (is_seekable) + if (is_seekable) { +#ifdef HAVE_UCHARDET file_encoding = detect_file_encoding(fp); +#else /* not HAVE_UCHARDET */ + file_encoding = NULL; +#endif /* not HAVE_UCHARDET */ + } if (!file_encoding) { if (is_debugging) fprintf(stderr, " could not detect encoding with uchardet\n"); -- 2.35.1
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach Files: Comment:
Depends on the following items: None found
Items that depend on this one: None found
There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.
Only logged-in users can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Follow 2 latest changes.
Copyright © 2023 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Source Code
Powered by Savane 3.9