diff options
-rw-r--r-- | src/einfo.h | 34 | ||||
-rw-r--r-- | src/libeinfo.c | 96 | ||||
-rw-r--r-- | src/librc-depend.c | 4 | ||||
-rw-r--r-- | src/rc.c | 18 |
4 files changed, 79 insertions, 73 deletions
diff --git a/src/einfo.h b/src/einfo.h index 7ab52afd..d274eefc 100644 --- a/src/einfo.h +++ b/src/einfo.h @@ -44,9 +44,13 @@ typedef enum /* 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 - subsequent calls are very fast. */ -/* 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 */ + subsequent calls are very fast. + The n suffix means that a newline is NOT appended to the string + 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); int einfon (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 eoutdent (void); -int veinfon (const char *fmt, ...) EINFO_PRINTF (1, 2); -int vewarnn (const char *fmt, ...) EINFO_PRINTF (1, 2); -int vebeginn (const char *fmt, ...) EINFO_PRINTF (1, 2); -int veendn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); -int vewendn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); -int veinfo (const char *fmt, ...) EINFO_PRINTF (1, 2); -int vewarn (const char *fmt, ...) EINFO_PRINTF (1, 2); -int vebegin (const char *fmt, ...) EINFO_PRINTF (1, 2); -int veend (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); -int vewend (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); -void veindent (void); -void veoutdent (void); +int einfovn (const char *fmt, ...) EINFO_PRINTF (1, 2); +int ewarnvn (const char *fmt, ...) EINFO_PRINTF (1, 2); +int ebeginvn (const char *fmt, ...) EINFO_PRINTF (1, 2); +int eendvn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); +int ewendvn (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); +int einfov (const char *fmt, ...) EINFO_PRINTF (1, 2); +int ewarnv (const char *fmt, ...) EINFO_PRINTF (1, 2); +int ebeginv (const char *fmt, ...) EINFO_PRINTF (1, 2); +int eendv (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); +int ewendv (int retval, const char *fmt, ...) EINFO_PRINTF (2, 3); +void eindentv (void); +void eoutdentv (void); /* If RC_EBUFFER is set, then we buffer all the above commands. As such, we need to flush the buffer when done. */ diff --git a/src/libeinfo.c b/src/libeinfo.c index b756d119..31c588f1 100644 --- a/src/libeinfo.c +++ b/src/libeinfo.c @@ -197,15 +197,15 @@ static const func_t funcmap[] = { { "ewend", NULL, &ewend, NULL }, { "eindent", NULL, NULL, &eindent }, { "eoutdent", NULL, NULL, &eoutdent }, - { "veinfon", &veinfon, NULL, NULL }, - { "vewarnn", &vewarnn, NULL, NULL }, - { "veinfo", &veinfo, NULL, NULL }, - { "vewarn", &vewarn, NULL, NULL }, - { "vebegin", &vebegin, NULL, NULL }, - { "veend", NULL, &veend, NULL }, - { "vewend", NULL, &vewend, NULL }, - { "veindent" ,NULL, NULL, &veindent }, - { "veoutdent", NULL, NULL, &veoutdent }, + { "einfovn", &einfovn, NULL, NULL }, + { "ewarnvn", &ewarnvn, NULL, NULL }, + { "einfov", &einfov, NULL, NULL }, + { "ewarnv", &ewarnv, NULL, NULL }, + { "ebeginv", &ebeginv, NULL, NULL }, + { "eendv", NULL, &eendv, NULL }, + { "ewendv", NULL, &ewendv, NULL }, + { "eindentv" ,NULL, NULL, &eindentv }, + { "eoutdentv", NULL, NULL, &eoutdentv }, { NULL, NULL, NULL, NULL }, }; @@ -391,7 +391,7 @@ static int _eindent (FILE *stream) return (fprintf (stream, "%s", indent)); } -#define VEINFON(_file, _colour) \ +#define EINFOVN(_file, _colour) \ if (colour_terminal ()) \ fprintf (_file, " " _colour "*" EINFO_NORMAL " "); \ else \ @@ -406,27 +406,27 @@ retval += _eindent (_file); \ if (colour_terminal ()) \ 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; - VEINFON (stdout, EINFO_GOOD); + EINFOVN (stdout, EINFO_GOOD); return (retval); } -static int _vewarnn (const char *fmt, va_list ap) +static int _ewarnvn (const char *fmt, va_list ap) { int retval = 0; - VEINFON (stdout, EINFO_WARN); + EINFOVN (stdout, EINFO_WARN); return (retval); } -static int _veerrorn (const char *fmt, va_list ap) +static int _eerrorvn (const char *fmt, va_list ap) { int retval = 0; - VEINFON (stderr, EINFO_BAD); + EINFOVN (stderr, EINFO_BAD); return (retval); } @@ -440,7 +440,7 @@ int einfon (const char *fmt, ...) va_start (ap, fmt); if (! (retval = ebuffer ("einfon", 0, fmt, ap))) - retval = _veinfon (fmt, ap); + retval = _einfovn (fmt, ap); va_end (ap); return (retval); @@ -456,7 +456,7 @@ int ewarnn (const char *fmt, ...) va_start (ap, fmt); if (! (retval = ebuffer ("ewarnn", 0, fmt, ap))) - retval = _vewarnn (fmt, ap); + retval = _ewarnvn (fmt, ap); va_end (ap); return (retval); @@ -469,7 +469,7 @@ int eerrorn (const char *fmt, ...) va_start (ap, fmt); if (! (retval = ebuffer ("eerrorn", 0, fmt, ap))) - retval = _veerrorn (fmt, ap); + retval = _eerrorvn (fmt, ap); va_end (ap); return (retval); @@ -486,7 +486,7 @@ int einfo (const char *fmt, ...) va_start (ap, fmt); if (! (retval = ebuffer ("einfo", 0, fmt, ap))) { - retval = _veinfon (fmt, ap); + retval = _einfovn (fmt, ap); retval += printf ("\n"); } va_end (ap); @@ -506,7 +506,7 @@ int ewarn (const char *fmt, ...) elog (LOG_WARNING, fmt, ap); if (! (retval = ebuffer ("ewarn", 0, fmt, ap))) { - retval = _vewarnn (fmt, ap); + retval = _ewarnvn (fmt, ap); retval += printf ("\n"); } va_end (ap); @@ -523,7 +523,7 @@ void ewarnx (const char *fmt, ...) { va_start (ap, fmt); elog (LOG_WARNING, fmt, ap); - retval = _vewarnn (fmt, ap); + retval = _ewarnvn (fmt, ap); va_end (ap); retval += printf ("\n"); } @@ -540,7 +540,7 @@ int eerror (const char *fmt, ...) va_start (ap, fmt); elog (LOG_ERR, fmt, ap); - retval = _veerrorn (fmt, ap); + retval = _eerrorvn (fmt, ap); va_end (ap); retval += fprintf (stderr, "\n"); @@ -555,7 +555,7 @@ void eerrorx (const char *fmt, ...) { va_start (ap, fmt); elog (LOG_ERR, fmt, ap); - _veerrorn (fmt, ap); + _eerrorvn (fmt, ap); va_end (ap); printf ("\n"); } @@ -577,7 +577,7 @@ int ebegin (const char *fmt, ...) return (retval); } - retval = _veinfon (fmt, ap); + retval = _einfovn (fmt, ap); va_end (ap); retval += printf (" ..."); 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); if (strcmp (cmd, "ewend") == 0) { - col = _vewarnn (fmt, apc); + col = _ewarnvn (fmt, apc); fp = stdout; } else { - col = _veerrorn (fmt, apc); + col = _eerrorvn (fmt, apc); fp = stderr; } va_end (apc); @@ -758,7 +758,7 @@ void eoutdent (void) } } -int veinfon (const char *fmt, ...) +int einfovn (const char *fmt, ...) { int retval; va_list ap; @@ -769,14 +769,14 @@ int veinfon (const char *fmt, ...) return (0); va_start (ap, fmt); - if (! (retval = ebuffer ("veinfon", 0, fmt, ap))) - retval = _veinfon (fmt, ap); + if (! (retval = ebuffer ("einfovn", 0, fmt, ap))) + retval = _einfovn (fmt, ap); va_end (ap); return (retval); } -int vewarnn (const char *fmt, ...) +int ewarnvn (const char *fmt, ...) { int retval; va_list ap; @@ -787,14 +787,14 @@ int vewarnn (const char *fmt, ...) return (0); va_start (ap, fmt); - if (! (retval = ebuffer ("vewarnn", 0, fmt, ap))) - retval = _vewarnn (fmt, ap); + if (! (retval = ebuffer ("ewarnvn", 0, fmt, ap))) + retval = _ewarnvn (fmt, ap); va_end (ap); return (retval); } -int veinfo (const char *fmt, ...) +int einfov (const char *fmt, ...) { int retval; va_list ap; @@ -805,9 +805,9 @@ int veinfo (const char *fmt, ...) return (0); 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"); } va_end (ap); @@ -815,7 +815,7 @@ int veinfo (const char *fmt, ...) return (retval); } -int vewarn (const char *fmt, ...) +int ewarnv (const char *fmt, ...) { int retval; va_list ap; @@ -826,9 +826,9 @@ int vewarn (const char *fmt, ...) return (0); 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"); } va_end (ap); @@ -837,7 +837,7 @@ int vewarn (const char *fmt, ...) return (retval); } -int vebegin (const char *fmt, ...) +int ebeginv (const char *fmt, ...) { int retval; va_list ap; @@ -848,9 +848,9 @@ int vebegin (const char *fmt, ...) return (0); 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 (" ..."); if (colour_terminal ()) retval += printf ("\n"); @@ -860,39 +860,39 @@ int vebegin (const char *fmt, ...) return (retval); } -int veend (int retval, const char *fmt, ...) +int eendv (int retval, const char *fmt, ...) { va_list ap; CHECK_VERBOSE; va_start (ap, fmt); - _do_eend ("veend", retval, fmt, ap); + _do_eend ("eendv", retval, fmt, ap); va_end (ap); return (retval); } -int vewend (int retval, const char *fmt, ...) +int ewendv (int retval, const char *fmt, ...) { va_list ap; CHECK_VERBOSE; va_start (ap, fmt); - _do_eend ("vewend", retval, fmt, ap); + _do_eend ("ewendv", retval, fmt, ap); va_end (ap); return (retval); } -void veindent (void) +void eindentv (void) { if (is_env ("RC_VERBOSE", "yes")) eindent (); } -void veoutdent (void) +void eoutdentv (void) { if (is_env ("RC_VERBOSE", "yes")) eoutdent (); diff --git a/src/librc-depend.c b/src/librc-depend.c index 93cc1f5c..f9b9bcd7 100644 --- a/src/librc-depend.c +++ b/src/librc-depend.c @@ -520,8 +520,10 @@ static bool is_newer_than (const char *file, const char *target) return (false); mtime = buf.st_mtime; + /* Of course we are newever than targets that don't exist + Such as broken symlinks */ if (stat (target, &buf) != 0) - return (false); + return (true); if (mtime < buf.st_mtime) return (false); @@ -184,27 +184,27 @@ static int do_e (int argc, char **argv) else if (strcmp (applet, "ewend") == 0) ewend (retval, fmt, message); else if (strcmp (applet, "veinfo") == 0) - veinfo (fmt, message); + einfov (fmt, message); else if (strcmp (applet, "veinfon") == 0) - veinfon (fmt, message); + einfovn (fmt, message); else if (strcmp (applet, "vewarn") == 0) - vewarn (fmt, message); + ewarnv (fmt, message); else if (strcmp (applet, "vewarnn") == 0) - vewarnn (fmt, message); + ewarnvn (fmt, message); else if (strcmp (applet, "vebegin") == 0) - vebegin (fmt, message); + ebeginv (fmt, message); else if (strcmp (applet, "veend") == 0) - veend (retval, fmt, message); + eendv (retval, fmt, message); else if (strcmp (applet, "vewend") == 0) - vewend (retval, fmt, message); + ewendv (retval, fmt, message); else if (strcmp (applet, "eindent") == 0) eindent (); else if (strcmp (applet, "eoutdent") == 0) eoutdent (); else if (strcmp (applet, "veindent") == 0) - veindent (); + eindentv (); else if (strcmp (applet, "veoutdent") == 0) - veoutdent (); + eoutdentv (); else if (strcmp (applet, "eflush") == 0) eflush (); else |