[Xfce4-commits] <xfce4-generic-slider:master> Reject non-numeric characters instead of working around them

Connor Behan noreply at xfce.org
Tue Nov 12 12:20:01 CET 2013


Updating branch refs/heads/master
         to 232857469114a903f32e00d74c61470fe99f28c5 (commit)
       from 08e92545ef843df22a23b7486661b870bb499841 (commit)

commit 232857469114a903f32e00d74c61470fe99f28c5
Author: Connor Behan <connor.behan at gmail.com>
Date:   Tue Nov 12 02:13:58 2013 -0800

    Reject non-numeric characters instead of working around them

 generic-slider.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/generic-slider.c b/generic-slider.c
index f3f12e0..28053b2 100644
--- a/generic-slider.c
+++ b/generic-slider.c
@@ -83,20 +83,14 @@ static gint timer_cb(Generic_Slider *generic_slider) {
 		/* Gets the output of the command knowing that numbers are 48 less than their ASCII equivalents */
 		for (i = 0; i < 3; i++) {
 			c = fgetc(stream);
-			
-			if (c != EOF) {
+						
+			if ((c >= 48) && (c <= 57)) {
 				new_value = (10 * new_value) + (c - 48);
 			} else {
 				break;
 			}
 		}
 		
-		/* For some reason a 2 gets stuck onto the end */
-		if (new_value != (generic_slider -> sync_denominator)) {
-			new_value -= 2;
-			new_value /= 10;
-		}
-		
 		if (new_value <= (generic_slider -> sync_denominator)) {
 			generic_slider -> value = ((double) new_value) / ((double) generic_slider -> sync_denominator);
 			gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(generic_slider -> slider), generic_slider -> value);


More information about the Xfce4-commits mailing list