From 3fafc7bbfa13c3e1da9c570872ae76e98b24a78e Mon Sep 17 00:00:00 2001 From: "Sean C. Rhea" Date: Thu, 30 Nov 2006 17:10:48 +0000 Subject: [PATCH] patches for Linux from Aldy Hernandez --- src/cmd/Makefile | 11 ++++++----- src/cmd/ptpk.c | 7 ++++--- src/lib/Makefile | 4 +++- src/lib/cpint.c | 2 ++ src/lib/pt.h | 3 ++- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/cmd/Makefile b/src/cmd/Makefile index 3ab517ffa..872939ff5 100644 --- a/src/cmd/Makefile +++ b/src/cmd/Makefile @@ -19,9 +19,10 @@ # CC=gcc -CFLAGS=-g -W -Wall -Werror -ansi -pedantic +CFLAGS=-g -W -Wall -Werror -ansi -pedantic -std=c99 CMDS=ptdl ptpk ptunpk cpint LIBS=../lib/libgc.a +LIBRARIES=-lm INCLUDES=-I../lib all: $(CMDS) @@ -34,16 +35,16 @@ clean: $(CC) -c $(CFLAGS) $(INCLUDES) $< cpint: cpint.o $(LIBS) - $(CXX) -o $@ $^ + $(CXX) -o $@ $^ $(LIBRARIES) ptdl: ptdl.o $(LIBS) - $(CC) -o $@ $^ + $(CC) -o $@ $^ $(LIBRARIES) ptunpk: ptunpk.o $(LIBS) - $(CC) -o $@ $^ + $(CC) -o $@ $^ $(LIBRARIES) ptpk: ptpk.o $(LIBS) - $(CC) -o $@ $^ + $(CC) -o $@ $^ $(LIBRARIES) ptdl.o: ../lib/pt.h ptunpk.o: ../lib/pt.h diff --git a/src/cmd/ptpk.c b/src/cmd/ptpk.c index 0ee8b55eb..724305feb 100644 --- a/src/cmd/ptpk.c +++ b/src/cmd/ptpk.c @@ -25,7 +25,6 @@ #include #include #include -#include #include "pt.h" void @@ -116,9 +115,11 @@ pt_pack(FILE *in, FILE *out, int wheel_sz_mm, int rec_int) hr = atoi(line + rider_pmatch[10].rm_so); interval = atoi(line + rider_pmatch[11].rm_so); if (mins - last_mins - 0.021 > 1.0 / 60.0) { + struct tm *tm_p; inc_time = start_time + round((mins - 0.021000001) * 60.0); - if (!localtime_r(&inc_time, &inc_tm)) - assert(0); + tm_p = localtime(&inc_time); + assert(tm_p); + inc_tm = *tm_p; pt_pack_time(buf, &inc_tm); pt_write_data(out, buf); pt_pack_config(buf, interval, rec_int, wheel_sz_mm); diff --git a/src/lib/Makefile b/src/lib/Makefile index dbf6b02a4..47a247981 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -19,7 +19,7 @@ # CC=gcc -CFLAGS=-g -W -Wall -Werror -ansi -pedantic +CFLAGS=-g -W -Wall -Werror -ansi -pedantic -std=c99 LIBTOOL=libtool all: libgc.a @@ -31,3 +31,5 @@ clean: libgc.a: pt.o cpint.o $(LIBTOOL) -static -o $@ $^ +pt.o: pt.h + diff --git a/src/lib/cpint.c b/src/lib/cpint.c index 3d2086ff0..ffaeee681 100644 --- a/src/lib/cpint.c +++ b/src/lib/cpint.c @@ -120,6 +120,7 @@ cpi_files_to_update(const char *dir) assert(0); dirp = opendir(dir); + assert(dirp); while ((dp = readdir(dirp)) != NULL) { int nmatch = 7; regmatch_t *pmatch = (regmatch_t*) calloc(nmatch, sizeof(regmatch_t)); @@ -302,6 +303,7 @@ combine_cpi_files(const char *dir, double *bests[], int *bestlen) *bests = calloc(*bestlen, sizeof(double)); inname = malloc(strlen(dir) + 25); dirp = opendir(dir); + assert(dirp); while ((dp = readdir(dirp)) != NULL) { if (strcmp(".cpi", dp->d_name + dp->d_namlen - 4) == 0) { sprintf(inname, "%s/%s", dir, dp->d_name); diff --git a/src/lib/pt.h b/src/lib/pt.h index 9b2a1c667..addfacfbd 100644 --- a/src/lib/pt.h +++ b/src/lib/pt.h @@ -23,7 +23,8 @@ #include #include -#include +#include +#include #define PT_DEBUG_NONE 0 #define PT_DEBUG_MAX 1