bugGNU roff - Bugs: bug #62985, [PATCH] preconv.cpp: move...

 
 

bug #62985: [PATCH] preconv.cpp: move conditional outside of the function "detect_file_encoding"

Submitter:  Bjarni Ingi Gislason <bjarniig>
Submitted:  Mon 29 Aug 2022 11:09:23 PM UTC
   
 
Category:  Preprocessor preconv Severity:  2 - Minor
Item Group:  Lint Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 29 Aug 2022 11:09:23 PM UTC, original submission:  

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


Bjarni Ingi Gislason <bjarniig>

 

(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

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Updated the item)
  • -email is unavailable- added by bjarniig (Submitted the item)
  •  

    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.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-30 gbranden Severity3 - Normal 2 - Minor
    2022-08-29 bjarniig Attached File- Added 0001-preconv.cpp-move-conditional-outside-of-the-function.txt, #53633

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code