[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #62985] [PATCH] preconv.cpp: move conditional outside of the functi
From: |
Bjarni Ingi Gislason |
Subject: |
[bug #62985] [PATCH] preconv.cpp: move conditional outside of the function "detect_file_encoding" |
Date: |
Mon, 29 Aug 2022 19:09:24 -0400 (EDT) |
URL:
<https://savannah.gnu.org/bugs/?62985>
Summary: [PATCH] preconv.cpp: move conditional outside of the
function "detect_file_encoding"
Project: GNU troff
Submitter: bjarniig
Submitted: Mon 29 Aug 2022 11:09:23 PM UTC
Category: Preprocessor preconv
Severity: 3 - Normal
Item Group: Lint
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
_______________________________________________________
Follow-up Comments:
-------------------------------------------------------
Date: Mon 29 Aug 2022 11:09:23 PM UTC By: Bjarni Ingi Gislason <bjarniig>
>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
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Mon 29 Aug 2022 11:09:23 PM UTC Name:
0001-preconv.cpp-move-conditional-outside-of-the-function.txt Size: 2KiB
By: bjarniig
<http://savannah.gnu.org/bugs/download.php?file_id=53633>
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?62985>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [bug #62985] [PATCH] preconv.cpp: move conditional outside of the function "detect_file_encoding",
Bjarni Ingi Gislason <=