[Kstars-devel] kdeedu/kstars/kstars

Jason Harris kstars at 30doradus.org
Tue Mar 2 02:22:30 CET 2004


CVS commit by harris: 

Fixing bug #76405:  when parsing a string as a dms angle 
value, the negative sign was lost if the degree field 
was 0.  For example, the string "-0 30 0" was interpreted 
as 0.5 degrees, not -0.5 degrees.

Fixed by adding a special case to dms::setFromString(): 
when the first field begins with '-' but is numerically 
equal to zero, the final angle is multiplied by -1.

Backporting to KDE_3_2_BRANCH (but too late for 3.2.1)

CCMAIL: 76405-done at bugs.kde.org
CCMAIL: kstars-devel at kde.org


  M +7 -2      dms.cpp   1.27


--- kdeedu/kstars/kstars/dms.cpp  #1.26:1.27
@@ -58,5 +58,5 @@ bool dms::setFromString( const QString &
         int d(0), m(0);
         double s(0.0);
-        bool checkValue( false ), badEntry( false );
+        bool checkValue( false ), badEntry( false ), negative( false );
         QString entry = str.stripWhiteSpace();
 
@@ -137,4 +137,5 @@ bool dms::setFromString( const QString &
         if ( fields.count() >= 3 ) {
                 //See if first two fields parse as integers, and third field as a double
+                
                 d = fields[0].toInt( &checkValue );
                 if ( !checkValue ) badEntry = true;
@@ -143,4 +144,8 @@ bool dms::setFromString( const QString &
                 s = fields[2].toDouble( &checkValue );
                 if ( !checkValue ) badEntry = true;
+                
+                //Special case: If first field is "-0", store the negative sign.  
+                //(otherwise it gets dropped)
+                if ( fields[0].at(0) == '-' && d == 0 ) negative = true;
         }
 
@@ -149,5 +154,5 @@ bool dms::setFromString( const QString &
                                 + (double)fabs(s)/3600.;
 
-                if ( d<0 || m < 0 || s<0 ) { D = -1.0*D;}
+                if ( negative || d<0 || m < 0 || s<0 ) { D = -1.0*D;}
 
                 if (isDeg) {




More information about the Kstars-devel mailing list