bug-datamash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/3] improve const correctness


From: Tim Rice
Subject: Re: [PATCH 3/3] improve const correctness
Date: Sun, 26 Jan 2025 20:43:23 +0000

Hi Georg,

Thanks for the additional patches.

The first two seem fine so far, but the third one results in a compiler error:

```
src/utils.c: In function 'extract_number':
src/utils.c:580:11: error: assignment discards 'const' qualifier from pointer 
target type [-Werror=discarded-qualifiers]
  580 |   pattern = extract_number_types[type].pattern;
      |           ^
```

~ Tim


On Sun, Jan 26, 2025 at 09:03:42PM +0100, Georg Sauthoff wrote:
---
src/text-options.c | 2 +-
src/text-options.h | 2 +-
src/utils.c        | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/text-options.c b/src/text-options.c
index 99c4793..deb7fd9 100644
--- a/src/text-options.c
+++ b/src/text-options.c
@@ -61,7 +61,7 @@ bool strict = true;

/* if 'strict' is false, lines with fewer-than-expected fields
   will be filled with this value */
-char* missing_field_filler = "N/A";
+const char* missing_field_filler = "N/A";

/* if true, skip comments line (lines starting with optional whitespace
   followed by '#' or ';'. See line_record_is_comment.  */
diff --git a/src/text-options.h b/src/text-options.h
index 1ec7606..a6a570e 100644
--- a/src/text-options.h
+++ b/src/text-options.h
@@ -62,7 +62,7 @@ extern bool strict;

/* if 'strict' is false, lines with fewer-than-expected fields
   will be filled with this value */
-extern char* missing_field_filler;
+extern const char* missing_field_filler;

/* if true, skip comments line (lines starting with optional whitespace
   followed by '#' or ';'. See line_record_is_comment.  */
diff --git a/src/utils.c b/src/utils.c
index 37367b5..417b5ca 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -538,7 +538,7 @@ guess_file_extension (const char*s, size_t len)

struct EXTRACT_NUMBER_TYPE
{
-  char *pattern;
+  const char *pattern;
  int base;
  bool floating_point;
};
--
2.47.1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]