diff --git a/src/dorem.c b/src/dorem.c index 42ee3dbd..7caa4e12 100644 --- a/src/dorem.c +++ b/src/dorem.c @@ -424,7 +424,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals) case T_Omit: DBufFree(&buf); if (trig->omitfunc[0]) { - Eprint("Warning: OMIT is ignored if you use OMITFUNC"); + Wprint("Warning: OMIT is ignored if you use OMITFUNC"); } r = ParseLocalOmit(s, trig); @@ -438,7 +438,7 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals) case T_OmitFunc: if (trig->localomit) { - Eprint("Warning: OMIT is ignored if you use OMITFUNC"); + Wprint("Warning: OMIT is ignored if you use OMITFUNC"); } r=ParseToken(s, &buf); if (r) return r; @@ -534,22 +534,22 @@ int ParseRem(ParsePtr s, Trigger *trig, TimeTrig *tim, int save_in_globals) if (!s->nonconst_expr) { if (trig->y != NO_YR && trig->m != NO_MON && trig->d != NO_DAY && trig->until != NO_UNTIL) { if (Julian(trig->y, trig->m, trig->d) > trig->until) { - Eprint("Warning: UNTIL/THROUGH date earlier than start date"); + Wprint("Warning: UNTIL/THROUGH date earlier than start date"); } } if (trig->from != NO_DATE) { if (trig->until != NO_UNTIL && trig->until < trig->from) { - Eprint("Warning: UNTIL/THROUGH date earlier than FROM date"); + Wprint("Warning: UNTIL/THROUGH date earlier than FROM date"); } } else if (trig->scanfrom != NO_DATE) { if (trig->until != NO_UNTIL && trig->until < trig->scanfrom) { - Eprint("Warning: UNTIL/THROUGH date earlier than SCANFROM date"); + Wprint("Warning: UNTIL/THROUGH date earlier than SCANFROM date"); } } } if (trig->y != NO_YR && trig->m != NO_MON && trig->d != NO_DAY && trig->until != NO_UNTIL && trig->rep == NO_REP) { - Eprint("Warning: Useless use of UNTIL with fully-specified date and no *rep"); + Wprint("Warning: Useless use of UNTIL with fully-specified date and no *rep"); } /* Set scanfrom to default if not set explicitly */ diff --git a/src/funcs.c b/src/funcs.c index 19962f63..ce8a4724 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -2414,8 +2414,7 @@ static int FPsshade(func_info *info) if (!psshade_warned) { psshade_warned = 1; - Eprint("psshade() is deprecated; use SPECIAL SHADE instead."); - FreshLine = 1; + Wprint("psshade() is deprecated; use SPECIAL SHADE instead."); } sprintf(s, "/_A LineWidth 2 div def "); @@ -2470,8 +2469,7 @@ static int FPsmoon(func_info *info) } if (!psmoon_warned) { psmoon_warned = 1; - Eprint("psmoon() is deprecated; use SPECIAL MOON instead."); - FreshLine = 1; + Wprint("psmoon() is deprecated; use SPECIAL MOON instead."); } if (size > 0) { sprintf(sizebuf, "%d", size); @@ -2988,7 +2986,7 @@ FEvalTrig(func_info *info) } else { /* Hokey... */ if (trig.scanfrom != JulianToday) { - Eprint("Warning: SCANFROM is ignored in two-argument form of evaltrig()"); + Wprint("Warning: SCANFROM is ignored in two-argument form of evaltrig()"); } jul = ComputeTrigger(scanfrom, &trig, &tim, &r, 0); } diff --git a/src/main.c b/src/main.c index 189fde9a..f35f460c 100644 --- a/src/main.c +++ b/src/main.c @@ -568,6 +568,29 @@ int EvaluateExpr(ParsePtr p, Value *v) return OK; } +/***************************************************************/ +/* */ +/* Wprint - print a warning message. */ +/* */ +/***************************************************************/ +void Wprint(char const *fmt, ...) +{ + va_list argptr; + + + if (FileName) { + if (strcmp(FileName, "-")) + (void) fprintf(ErrFp, "%s(%d): ", FileName, LineNo); + else + (void) fprintf(ErrFp, "-stdin-(%d): ", LineNo); + } + + va_start(argptr, fmt); + (void) vfprintf(ErrFp, fmt, argptr); + (void) fputc('\n', ErrFp); + va_end(argptr); + return; +} /***************************************************************/ /* */ /* Eprint - print an error message. */ diff --git a/src/omit.c b/src/omit.c index db77c1fe..b0818ffd 100644 --- a/src/omit.c +++ b/src/omit.c @@ -463,7 +463,7 @@ DoThroughOmit(ParsePtr p, int ystart, int mstart, int dstart) end = Julian(yend, mend, dend); if (end < start) { - Eprint("Warning: Swapping dates on OMIT ... THROUGH ... line"); + Wprint("Warning: Swapping dates on OMIT ... THROUGH ... line"); tmp = start; start = end; end = tmp; diff --git a/src/protos.h b/src/protos.h index 535ec02d..99a2f9cc 100644 --- a/src/protos.h +++ b/src/protos.h @@ -62,6 +62,7 @@ int EvaluateExpr (ParsePtr p, Value *v); int Evaluate (char const **s, Var *locals, ParsePtr p); int FnPopValStack (Value *val); void Eprint (char const *fmt, ...); +void Wprint (char const *fmt, ...); void OutputLine (FILE *fp); void CreateParser (char const *s, ParsePtr p); void DestroyParser (ParsePtr p); diff --git a/src/userfns.c b/src/userfns.c index 6dda2e7c..971a9809 100644 --- a/src/userfns.c +++ b/src/userfns.c @@ -167,7 +167,7 @@ int DoFset(ParsePtr p) /* Add the function definition */ FSet(func); if (orig_namelen > VAR_NAME_LEN) { - Eprint("Warning: Function name `%s...' truncated to `%s'", + Wprint("Warning: Function name `%s...' truncated to `%s'", func->name, func->name); } return OK; diff --git a/src/var.c b/src/var.c index 400972e6..31074739 100644 --- a/src/var.c +++ b/src/var.c @@ -43,8 +43,7 @@ typedef int (*SysVarFunc)(int, Value *); static void deprecated_var(char const *var, char const *instead) { if (DebugFlag & DB_PRTLINE) { - Eprint("%s is deprecated; use %s instead", var, instead); - FreshLine = 1; + Wprint("%s is deprecated; use %s instead", var, instead); } } @@ -508,7 +507,7 @@ int DoSet (Parser *p) if (*DBufValue(&buf) == '$') r = SetSysVar(DBufValue(&buf)+1, &v); else r = SetVar(DBufValue(&buf), &v); if (buf.len > VAR_NAME_LEN) { - Eprint("Warning: Variable name `%.*s...' truncated to `%.*s'", + Wprint("Warning: Variable name `%.*s...' truncated to `%.*s'", VAR_NAME_LEN, DBufValue(&buf), VAR_NAME_LEN, DBufValue(&buf)); } DBufFree(&buf); @@ -908,9 +907,7 @@ int GetSysVar(char const *name, Value *val) /* In "verbose" mode, print attempts to test $RunOff */ if (DebugFlag & DB_PRTLINE) { if (v->value == (void *) &RunDisabled) { - Eprint("(Security note: $RunOff variable tested.)"); - /* Allow further messages from this line */ - FreshLine = 1; + Wprint("(Security note: $RunOff variable tested.)"); } } return OK;