diff --git a/Makefile b/Makefile index 80db525..448fa40 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,9 @@ WARNFLAGS= -Wsystem-headers -Wall -W -Wno-unused-parameter \ VER_FLAGS= -DMAJ_VER=$(MAJ_VER) -DMIN_VER=$(MIN_VER) -CFLAGS= $(WARNFLAGS) $(VER_FLAGS) -std=c99 -D_BSD_SOURCE +INCDIR?= +LIBDIR?= +CFLAGS= -I$(INCDIR) -L$(LIBDIR) $(WARNFLAGS) $(VER_FLAGS) -std=c99 -D_BSD_SOURCE CFLAGS_DEBUG= -O0 -g3 CFLAGS_OPT= -O4 -flto LDFLAGS= diff --git a/README.md b/README.md index b48964d..62dad3a 100644 --- a/README.md +++ b/README.md @@ -334,3 +334,7 @@ Just type make +Or if your package manager installs software in a different place: + + env INCDIR=/path/to/include LIBDIR=/path/to/lib make + diff --git a/calc.h b/calc.h index 1bf0fcc..188043b 100644 --- a/calc.h +++ b/calc.h @@ -30,6 +30,7 @@ #ifndef _CALC_H #define _CALC_H +#include #include "parse_ctx.h" #define MAX_HIST_LEN 1000 @@ -55,4 +56,6 @@ int yy_input_helper(char *buf, size_t max_size); int yyparse(struct parse_ctx *ctx); void mode_switch(char new_mode); void graceful_exit(void); +int require_file(const char *, int); +int require_fd(FILE *, const char *, int); #endif diff --git a/calc.l b/calc.l index 973aa69..09857b0 100644 --- a/calc.l +++ b/calc.l @@ -5,6 +5,8 @@ %option bison-bridge %option bison-locations +%option nounput + %{ # include # include @@ -20,6 +22,7 @@ # include "parse_ctx.h" # include "calc.tab.h" +#define YY_NO_INPUT #define YY_EXTRA_TYPE struct parse_ctx * #define YY_USER_ACTION yylloc->first_line = yylineno; diff --git a/calc.y b/calc.y index 908a1c7..72430c9 100644 --- a/calc.y +++ b/calc.y @@ -28,6 +28,7 @@ #include "lex.yy.h" # define scanner ctx->scanner +void yyerror(YYLTYPE *locp, struct parse_ctx *ctx, const char *s, ...); void yyerror(YYLTYPE *locp, struct parse_ctx *ctx, const char *s, ...) diff --git a/main.c b/main.c index 4940f70..9b83c83 100644 --- a/main.c +++ b/main.c @@ -204,7 +204,6 @@ sig_handler(int sig) } } -static int require_fd(FILE *fp, const char *fname, int silent) { @@ -222,6 +221,7 @@ require_fd(FILE *fp, const char *fname, int silent) return 0; } + int require_file(const char *file, int silent) { @@ -260,8 +260,6 @@ load_rc(void) { struct dirent **namelist; char p[4096]; - FILE *fp; - DIR *dp; int n; /* Load rc file, if it exists */ @@ -282,7 +280,6 @@ int main(int argc, char *argv[]) { struct parse_ctx ctx; - char *progname = argv[0]; char *line; int len; int error; diff --git a/num.c b/num.c index fea6222..215eb09 100644 --- a/num.c +++ b/num.c @@ -84,8 +84,6 @@ static mpfr_prec_t num_prec(num_t a) { - mpfr_prec_t prec; - if (a != NULL && a->num_type == NUM_INT) { /* XXX: completely arbitrary! */ return 2048; diff --git a/parse_ctx.h b/parse_ctx.h index 8cb2cfb..0696b42 100644 --- a/parse_ctx.h +++ b/parse_ctx.h @@ -2,7 +2,7 @@ #define _PARSE_CTX_H struct parse_ctx { - char *filename; + const char *filename; void *scanner; int interactive;