Change veinfo and friends to einfov. Rationale - we may need veinfo to support va_list in the future.

This commit is contained in:
Roy Marples 2007-04-10 16:11:20 +00:00
parent 240399534c
commit ffc96d8d89
4 changed files with 79 additions and 73 deletions

View File

@ -44,9 +44,13 @@ typedef enum
/* We work out if the terminal supports colour or not through the use /* We work out if the terminal supports colour or not through the use
of the TERM env var. We cache the reslt in a static bool, so of the TERM env var. We cache the reslt in a static bool, so
subsequent calls are very fast. */ subsequent calls are very fast.
/* The n suffix means that a newline is NOT appended to the string The n suffix means that a newline is NOT appended to the string
The v prefix means that we only print it when RC_VERBOSE=yes */ The v suffix means that we only print it when RC_VERBOSE=yes
NOTE We use the v suffix here so we can add veinfo for va_list
in the future, but veinfo is used by shell scripts as they don't
have the va_list concept
*/
bool colour_terminal (void); bool colour_terminal (void);
int einfon (const char *fmt, ...) EINFO_PRINTF (1, 2); int einfon (const char *fmt, ...) EINFO_PRINTF (1, 2);
int ewarnn (const char *fmt, ...) EINFO_PRINTF (1, 2); int ewarnn (const char *fmt, ...) EINFO_PRINTF (1, 2);
@ -63,18 +67,18 @@ void ebracket (int col, einfo_color_t color, const char *msg);
void eindent (void); void eindent (void);
void eoutdent (void); void eoutdent (void);
int veinfon (const char *fmt, ...) EINFO_PRINTF (1, 2); int einfovn (const char *fmt, ...) EINFO_PRINTF (1, 2);
int vewarnn (const char *fmt, ...) EINFO_PRINTF (1, 2); int ewarnvn (const char *fmt, ...) EINFO_PRINTF (1, 2);
int vebeginn (const char *fmt, ...) EINFO_PRINTF (1, 2); int ebeginvn (const char *fmt, ...) EINFO_PRINTF (1, 2);
int veendn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); int eendvn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
int vewendn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); int ewendvn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
int veinfo (const char *fmt, ...) EINFO_PRINTF (1, 2); int einfov (const char *fmt, ...) EINFO_PRINTF (1, 2);
int vewarn (const char *fmt, ...) EINFO_PRINTF (1, 2); int ewarnv (const char *fmt, ...) EINFO_PRINTF (1, 2);
int vebegin (const char *fmt, ...) EINFO_PRINTF (1, 2); int ebeginv (const char *fmt, ...) EINFO_PRINTF (1, 2);
int veend (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); int eendv (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
int vewend (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); int ewendv (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3);
void veindent (void); void eindentv (void);
void veoutdent (void); void eoutdentv (void);
/* If RC_EBUFFER is set, then we buffer all the above commands. /* If RC_EBUFFER is set, then we buffer all the above commands.
As such, we need to flush the buffer when done. */ As such, we need to flush the buffer when done. */

View File

@ -197,15 +197,15 @@ static const func_t funcmap[] = {
{ "ewend", NULL, &ewend, NULL }, { "ewend", NULL, &ewend, NULL },
{ "eindent", NULL, NULL, &eindent }, { "eindent", NULL, NULL, &eindent },
{ "eoutdent", NULL, NULL, &eoutdent }, { "eoutdent", NULL, NULL, &eoutdent },
{ "veinfon", &veinfon, NULL, NULL }, { "einfovn", &einfovn, NULL, NULL },
{ "vewarnn", &vewarnn, NULL, NULL }, { "ewarnvn", &ewarnvn, NULL, NULL },
{ "veinfo", &veinfo, NULL, NULL }, { "einfov", &einfov, NULL, NULL },
{ "vewarn", &vewarn, NULL, NULL }, { "ewarnv", &ewarnv, NULL, NULL },
{ "vebegin", &vebegin, NULL, NULL }, { "ebeginv", &ebeginv, NULL, NULL },
{ "veend", NULL, &veend, NULL }, { "eendv", NULL, &eendv, NULL },
{ "vewend", NULL, &vewend, NULL }, { "ewendv", NULL, &ewendv, NULL },
{ "veindent" ,NULL, NULL, &veindent }, { "eindentv" ,NULL, NULL, &eindentv },
{ "veoutdent", NULL, NULL, &veoutdent }, { "eoutdentv", NULL, NULL, &eoutdentv },
{ NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL },
}; };
@ -391,7 +391,7 @@ static int _eindent (FILE *stream)
return (fprintf (stream, "%s", indent)); return (fprintf (stream, "%s", indent));
} }
#define VEINFON(_file, _colour) \ #define EINFOVN(_file, _colour) \
if (colour_terminal ()) \ if (colour_terminal ()) \
fprintf (_file, " " _colour "*" EINFO_NORMAL " "); \ fprintf (_file, " " _colour "*" EINFO_NORMAL " "); \
else \ else \
@ -406,27 +406,27 @@ retval += _eindent (_file); \
if (colour_terminal ()) \ if (colour_terminal ()) \
fprintf (_file, "\033[K"); fprintf (_file, "\033[K");
static int _veinfon (const char *fmt, va_list ap) static int _einfovn (const char *fmt, va_list ap)
{ {
int retval = 0; int retval = 0;
VEINFON (stdout, EINFO_GOOD); EINFOVN (stdout, EINFO_GOOD);
return (retval); return (retval);
} }
static int _vewarnn (const char *fmt, va_list ap) static int _ewarnvn (const char *fmt, va_list ap)
{ {
int retval = 0; int retval = 0;
VEINFON (stdout, EINFO_WARN); EINFOVN (stdout, EINFO_WARN);
return (retval); return (retval);
} }
static int _veerrorn (const char *fmt, va_list ap) static int _eerrorvn (const char *fmt, va_list ap)
{ {
int retval = 0; int retval = 0;
VEINFON (stderr, EINFO_BAD); EINFOVN (stderr, EINFO_BAD);
return (retval); return (retval);
} }
@ -440,7 +440,7 @@ int einfon (const char *fmt, ...)
va_start (ap, fmt); va_start (ap, fmt);
if (! (retval = ebuffer ("einfon", 0, fmt, ap))) if (! (retval = ebuffer ("einfon", 0, fmt, ap)))
retval = _veinfon (fmt, ap); retval = _einfovn (fmt, ap);
va_end (ap); va_end (ap);
return (retval); return (retval);
@ -456,7 +456,7 @@ int ewarnn (const char *fmt, ...)
va_start (ap, fmt); va_start (ap, fmt);
if (! (retval = ebuffer ("ewarnn", 0, fmt, ap))) if (! (retval = ebuffer ("ewarnn", 0, fmt, ap)))
retval = _vewarnn (fmt, ap); retval = _ewarnvn (fmt, ap);
va_end (ap); va_end (ap);
return (retval); return (retval);
@ -469,7 +469,7 @@ int eerrorn (const char *fmt, ...)
va_start (ap, fmt); va_start (ap, fmt);
if (! (retval = ebuffer ("eerrorn", 0, fmt, ap))) if (! (retval = ebuffer ("eerrorn", 0, fmt, ap)))
retval = _veerrorn (fmt, ap); retval = _eerrorvn (fmt, ap);
va_end (ap); va_end (ap);
return (retval); return (retval);
@ -486,7 +486,7 @@ int einfo (const char *fmt, ...)
va_start (ap, fmt); va_start (ap, fmt);
if (! (retval = ebuffer ("einfo", 0, fmt, ap))) if (! (retval = ebuffer ("einfo", 0, fmt, ap)))
{ {
retval = _veinfon (fmt, ap); retval = _einfovn (fmt, ap);
retval += printf ("\n"); retval += printf ("\n");
} }
va_end (ap); va_end (ap);
@ -506,7 +506,7 @@ int ewarn (const char *fmt, ...)
elog (LOG_WARNING, fmt, ap); elog (LOG_WARNING, fmt, ap);
if (! (retval = ebuffer ("ewarn", 0, fmt, ap))) if (! (retval = ebuffer ("ewarn", 0, fmt, ap)))
{ {
retval = _vewarnn (fmt, ap); retval = _ewarnvn (fmt, ap);
retval += printf ("\n"); retval += printf ("\n");
} }
va_end (ap); va_end (ap);
@ -523,7 +523,7 @@ void ewarnx (const char *fmt, ...)
{ {
va_start (ap, fmt); va_start (ap, fmt);
elog (LOG_WARNING, fmt, ap); elog (LOG_WARNING, fmt, ap);
retval = _vewarnn (fmt, ap); retval = _ewarnvn (fmt, ap);
va_end (ap); va_end (ap);
retval += printf ("\n"); retval += printf ("\n");
} }
@ -540,7 +540,7 @@ int eerror (const char *fmt, ...)
va_start (ap, fmt); va_start (ap, fmt);
elog (LOG_ERR, fmt, ap); elog (LOG_ERR, fmt, ap);
retval = _veerrorn (fmt, ap); retval = _eerrorvn (fmt, ap);
va_end (ap); va_end (ap);
retval += fprintf (stderr, "\n"); retval += fprintf (stderr, "\n");
@ -555,7 +555,7 @@ void eerrorx (const char *fmt, ...)
{ {
va_start (ap, fmt); va_start (ap, fmt);
elog (LOG_ERR, fmt, ap); elog (LOG_ERR, fmt, ap);
_veerrorn (fmt, ap); _eerrorvn (fmt, ap);
va_end (ap); va_end (ap);
printf ("\n"); printf ("\n");
} }
@ -577,7 +577,7 @@ int ebegin (const char *fmt, ...)
return (retval); return (retval);
} }
retval = _veinfon (fmt, ap); retval = _einfovn (fmt, ap);
va_end (ap); va_end (ap);
retval += printf (" ..."); retval += printf (" ...");
if (colour_terminal ()) if (colour_terminal ())
@ -655,12 +655,12 @@ static int _do_eend (const char *cmd, int retval, const char *fmt, va_list ap)
va_copy (apc, ap); va_copy (apc, ap);
if (strcmp (cmd, "ewend") == 0) if (strcmp (cmd, "ewend") == 0)
{ {
col = _vewarnn (fmt, apc); col = _ewarnvn (fmt, apc);
fp = stdout; fp = stdout;
} }
else else
{ {
col = _veerrorn (fmt, apc); col = _eerrorvn (fmt, apc);
fp = stderr; fp = stderr;
} }
va_end (apc); va_end (apc);
@ -758,7 +758,7 @@ void eoutdent (void)
} }
} }
int veinfon (const char *fmt, ...) int einfovn (const char *fmt, ...)
{ {
int retval; int retval;
va_list ap; va_list ap;
@ -769,14 +769,14 @@ int veinfon (const char *fmt, ...)
return (0); return (0);
va_start (ap, fmt); va_start (ap, fmt);
if (! (retval = ebuffer ("veinfon", 0, fmt, ap))) if (! (retval = ebuffer ("einfovn", 0, fmt, ap)))
retval = _veinfon (fmt, ap); retval = _einfovn (fmt, ap);
va_end (ap); va_end (ap);
return (retval); return (retval);
} }
int vewarnn (const char *fmt, ...) int ewarnvn (const char *fmt, ...)
{ {
int retval; int retval;
va_list ap; va_list ap;
@ -787,14 +787,14 @@ int vewarnn (const char *fmt, ...)
return (0); return (0);
va_start (ap, fmt); va_start (ap, fmt);
if (! (retval = ebuffer ("vewarnn", 0, fmt, ap))) if (! (retval = ebuffer ("ewarnvn", 0, fmt, ap)))
retval = _vewarnn (fmt, ap); retval = _ewarnvn (fmt, ap);
va_end (ap); va_end (ap);
return (retval); return (retval);
} }
int veinfo (const char *fmt, ...) int einfov (const char *fmt, ...)
{ {
int retval; int retval;
va_list ap; va_list ap;
@ -805,9 +805,9 @@ int veinfo (const char *fmt, ...)
return (0); return (0);
va_start (ap, fmt); va_start (ap, fmt);
if (! (retval = ebuffer ("veinfo", 0, fmt, ap))) if (! (retval = ebuffer ("einfov", 0, fmt, ap)))
{ {
retval = _veinfon (fmt, ap); retval = _einfovn (fmt, ap);
retval += printf ("\n"); retval += printf ("\n");
} }
va_end (ap); va_end (ap);
@ -815,7 +815,7 @@ int veinfo (const char *fmt, ...)
return (retval); return (retval);
} }
int vewarn (const char *fmt, ...) int ewarnv (const char *fmt, ...)
{ {
int retval; int retval;
va_list ap; va_list ap;
@ -826,9 +826,9 @@ int vewarn (const char *fmt, ...)
return (0); return (0);
va_start (ap, fmt); va_start (ap, fmt);
if (! (retval = ebuffer ("vewarn", 0, fmt, ap))) if (! (retval = ebuffer ("ewarnv", 0, fmt, ap)))
{ {
retval = _vewarnn (fmt, ap); retval = _ewarnvn (fmt, ap);
retval += printf ("\n"); retval += printf ("\n");
} }
va_end (ap); va_end (ap);
@ -837,7 +837,7 @@ int vewarn (const char *fmt, ...)
return (retval); return (retval);
} }
int vebegin (const char *fmt, ...) int ebeginv (const char *fmt, ...)
{ {
int retval; int retval;
va_list ap; va_list ap;
@ -848,9 +848,9 @@ int vebegin (const char *fmt, ...)
return (0); return (0);
va_start (ap, fmt); va_start (ap, fmt);
if (! (retval = ebuffer ("vewarn", 0, fmt, ap))) if (! (retval = ebuffer ("ebeginv", 0, fmt, ap)))
{ {
retval = _veinfon (fmt, ap); retval = _einfovn (fmt, ap);
retval += printf (" ..."); retval += printf (" ...");
if (colour_terminal ()) if (colour_terminal ())
retval += printf ("\n"); retval += printf ("\n");
@ -860,39 +860,39 @@ int vebegin (const char *fmt, ...)
return (retval); return (retval);
} }
int veend (int retval, const char *fmt, ...) int eendv (int retval, const char *fmt, ...)
{ {
va_list ap; va_list ap;
CHECK_VERBOSE; CHECK_VERBOSE;
va_start (ap, fmt); va_start (ap, fmt);
_do_eend ("veend", retval, fmt, ap); _do_eend ("eendv", retval, fmt, ap);
va_end (ap); va_end (ap);
return (retval); return (retval);
} }
int vewend (int retval, const char *fmt, ...) int ewendv (int retval, const char *fmt, ...)
{ {
va_list ap; va_list ap;
CHECK_VERBOSE; CHECK_VERBOSE;
va_start (ap, fmt); va_start (ap, fmt);
_do_eend ("vewend", retval, fmt, ap); _do_eend ("ewendv", retval, fmt, ap);
va_end (ap); va_end (ap);
return (retval); return (retval);
} }
void veindent (void) void eindentv (void)
{ {
if (is_env ("RC_VERBOSE", "yes")) if (is_env ("RC_VERBOSE", "yes"))
eindent (); eindent ();
} }
void veoutdent (void) void eoutdentv (void)
{ {
if (is_env ("RC_VERBOSE", "yes")) if (is_env ("RC_VERBOSE", "yes"))
eoutdent (); eoutdent ();

View File

@ -520,8 +520,10 @@ static bool is_newer_than (const char *file, const char *target)
return (false); return (false);
mtime = buf.st_mtime; mtime = buf.st_mtime;
/* Of course we are newever than targets that don't exist
Such as broken symlinks */
if (stat (target, &buf) != 0) if (stat (target, &buf) != 0)
return (false); return (true);
if (mtime < buf.st_mtime) if (mtime < buf.st_mtime)
return (false); return (false);

View File

@ -184,27 +184,27 @@ static int do_e (int argc, char **argv)
else if (strcmp (applet, "ewend") == 0) else if (strcmp (applet, "ewend") == 0)
ewend (retval, fmt, message); ewend (retval, fmt, message);
else if (strcmp (applet, "veinfo") == 0) else if (strcmp (applet, "veinfo") == 0)
veinfo (fmt, message); einfov (fmt, message);
else if (strcmp (applet, "veinfon") == 0) else if (strcmp (applet, "veinfon") == 0)
veinfon (fmt, message); einfovn (fmt, message);
else if (strcmp (applet, "vewarn") == 0) else if (strcmp (applet, "vewarn") == 0)
vewarn (fmt, message); ewarnv (fmt, message);
else if (strcmp (applet, "vewarnn") == 0) else if (strcmp (applet, "vewarnn") == 0)
vewarnn (fmt, message); ewarnvn (fmt, message);
else if (strcmp (applet, "vebegin") == 0) else if (strcmp (applet, "vebegin") == 0)
vebegin (fmt, message); ebeginv (fmt, message);
else if (strcmp (applet, "veend") == 0) else if (strcmp (applet, "veend") == 0)
veend (retval, fmt, message); eendv (retval, fmt, message);
else if (strcmp (applet, "vewend") == 0) else if (strcmp (applet, "vewend") == 0)
vewend (retval, fmt, message); ewendv (retval, fmt, message);
else if (strcmp (applet, "eindent") == 0) else if (strcmp (applet, "eindent") == 0)
eindent (); eindent ();
else if (strcmp (applet, "eoutdent") == 0) else if (strcmp (applet, "eoutdent") == 0)
eoutdent (); eoutdent ();
else if (strcmp (applet, "veindent") == 0) else if (strcmp (applet, "veindent") == 0)
veindent (); eindentv ();
else if (strcmp (applet, "veoutdent") == 0) else if (strcmp (applet, "veoutdent") == 0)
veoutdent (); eoutdentv ();
else if (strcmp (applet, "eflush") == 0) else if (strcmp (applet, "eflush") == 0)
eflush (); eflush ();
else else