[MN-dev] [mndiff]: r168 - trunk/ffvotetov/ffvotetov.c

michael subversion at mplayerhq.hu
Wed Dec 16 02:25:42 CET 2009


Author: michael
Date: Wed Dec 16 02:25:42 2009
New Revision: 168

Log:
Detect vote boundaries by non parseable lines instead of non monotonicity.

Modified:
   trunk/ffvotetov/ffvotetov.c

Modified: trunk/ffvotetov/ffvotetov.c
==============================================================================
--- trunk/ffvotetov/ffvotetov.c	Wed Dec 16 02:10:39 2009	(r167)
+++ trunk/ffvotetov/ffvotetov.c	Wed Dec 16 02:25:42 2009	(r168)
@@ -228,7 +228,6 @@ int main(){
     int i,j, k, num, cand_idx;
     int64_t max;
     char line[1000], *p;
-    int last_num=-1;
     int vote[CANDIDATES_MAX]={0};
 
     //very lame parser below, this is not robust nor tamper proof,only use with manually checked input!
@@ -236,8 +235,6 @@ int main(){
         scanf("%999[^\n]\n", line);
         num= strtol(line, &p, 0);
         if(num>0){
-            if(last_num >= num)
-                add_vote(vote);
             p+= strspn(p, " .:,;()[]{}=-_#~|");
             for(cand_idx=0; cand_idx<canditate_count; cand_idx++)
                 if(!strcasecmp(canditates[cand_idx], p))
@@ -250,9 +247,9 @@ int main(){
                 strncpy(canditates[canditate_count++], p, CANDIDATE_LEN-1);
             }
             vote[cand_idx]= num;
-            last_num=num;
             fprintf(stderr, "Parsed as:%d %s\n", num, p);
-        }
+        }else
+            add_vote(vote);
     }
     add_vote(vote);
     for(j=0; j<canditate_count; j++)


More information about the Mndiff-dev mailing list