gnuastro-commits
[Top][All Lists]
Advanced

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

[gnuastro-commits] master edcf9246: Arithmetic: physical constants retur


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master edcf9246: Arithmetic: physical constants returned without crash
Date: Mon, 1 Jul 2024 15:28:41 -0400 (EDT)

branch: master
commit edcf92468baa8e0e0e9f3b1ab85bf3e908405976
Author: Mohammad Akhlaghi <mohammad@akhlaghi.org>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Arithmetic: physical constants returned without crash
    
    Until now, when Arithmetic was given a physical constant (like 'c' for the
    speed of light; as in 'astarithmetic c'), it would crash by complaining
    that the constant's code is not recognized.
    
    With this commit, the problem was found to be in the absense of any
    'break;' within the 'case' that searched the constants.
    
    This fixes bug #65935.
---
 NEWS             |  2 ++
 lib/arithmetic.c | 14 +++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/NEWS b/NEWS
index c0e7da44..aba6ab5e 100644
--- a/NEWS
+++ b/NEWS
@@ -221,6 +221,8 @@ See the end of the file for license conditions.
   - bug #65862: Output directory ignored when Statistics is called with
     the '--ontile' option.
 
+  - bug #65935: Arithmetic crashes with constants like speed of light.
+
 
 
 
diff --git a/lib/arithmetic.c b/lib/arithmetic.c
index f5509f31..519e5751 100644
--- a/lib/arithmetic.c
+++ b/lib/arithmetic.c
@@ -3597,19 +3597,19 @@ arithmetic_constants_standard(int operator)
     case GAL_ARITHMETIC_OP_PI:    /* Circle circumfernece to diameter. */
       value[0]=M_PI; break;
     case GAL_ARITHMETIC_OP_C:                   /* The speed of light. */
-      value[0]=GSL_CONST_MKS_SPEED_OF_LIGHT;
+      value[0]=GSL_CONST_MKS_SPEED_OF_LIGHT; break;
     case GAL_ARITHMETIC_OP_G:           /* The gravitational constant. */
-      value[0]=GSL_CONST_MKS_GRAVITATIONAL_CONSTANT;
+      value[0]=GSL_CONST_MKS_GRAVITATIONAL_CONSTANT; break;
     case GAL_ARITHMETIC_OP_H:                     /* Plank's constant. */
-      value[0]=GSL_CONST_MKS_PLANCKS_CONSTANT_H;
+      value[0]=GSL_CONST_MKS_PLANCKS_CONSTANT_H; break;
     case GAL_ARITHMETIC_OP_AU:       /* Astronomical Unit (in meters). */
-      value[0]=GSL_CONST_MKS_ASTRONOMICAL_UNIT;
+      value[0]=GSL_CONST_MKS_ASTRONOMICAL_UNIT; break;
     case GAL_ARITHMETIC_OP_LY:             /* Light years (in meters). */
-      value[0]=GSL_CONST_MKS_LIGHT_YEAR;
+      value[0]=GSL_CONST_MKS_LIGHT_YEAR; break;
     case GAL_ARITHMETIC_OP_AVOGADRO:             /* Avogadro's number. */
-      value[0]=GSL_CONST_NUM_AVOGADRO;
+      value[0]=GSL_CONST_NUM_AVOGADRO; break;
     case GAL_ARITHMETIC_OP_FINESTRUCTURE:  /* Fine-structure constant. */
-      value[0]=GSL_CONST_NUM_FINE_STRUCTURE;
+      value[0]=GSL_CONST_NUM_FINE_STRUCTURE; break;
 
     default:
       error(EXIT_FAILURE, 0, "%s: a bug! Please contact us at '%s' to "



reply via email to

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