Changeset f7045c5 in subsurface


Ignore:
Timestamp:
Feb 10, 2017, 8:30:58 PM (7 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
8b2de77
Parents:
7c91cdd
git-author:
Salvador Cuñat <salvador.cunat@…> (01/22/17 05:05:06)
git-committer:
Dirk Hohndel <dirk@…> (02/10/17 20:30:58)
Message:

smtk-import-improve smtk_time_to_secs()

Can't remember what I was thinking when wrote that crappy thing. A
simple sscanf call will do the job, and a sanity check, off course.

Signed-off-by: Salvador Cuñat <salvador.cunat@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • smtk-import/smartrak.c

    r7c91cdd rf7045c5  
    119119static unsigned int smtk_time_to_secs(char *t_buffer)
    120120{
    121         char *temp;
    122         unsigned int hr, min, sec;
     121        unsigned int n, hr, min, sec;
    123122
    124123        if (!same_string(t_buffer, "")) {
    125                 temp = rindex(copy_string(t_buffer), ' ');
    126                 hr = atoi(strtok(temp, ":"));
    127                 min = atoi(strtok(NULL, ":"));
    128                 sec = atoi(strtok(NULL, "\0"));
    129                 return((((hr*60)+min)*60)+sec);
     124                n = sscanf(t_buffer, "%*m[/0-9] %d:%d:%d ", &hr, &min, &sec);
     125                return((n == 3) ? (((hr*60)+min)*60)+sec : 0);
    130126        } else {
    131127                return 0;
Note: See TracChangeset for help on using the changeset viewer.