diff options
author | Paul Smith <psmith@gnu.org> | 2013-11-23 22:23:52 -0500 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2013-11-23 22:23:52 -0500 |
commit | 757849cd93a9bc361a5113e3aaafe516773aad44 (patch) | |
tree | d6acd1705fe25873b43fa7d16b736e44b6191ab7 /remake.c | |
parent | 9d58570c77240fed53d1f88217877f8e778f4bb2 (diff) | |
download | gunmake-757849cd93a9bc361a5113e3aaafe516773aad44.tar.gz |
[SV 40361] Don't use vsnprintf(), which is an ISO C99 function.
* output.c (error, fatal, message): Take an extra argument specifying
how many bytes are used by the formatted arguments.
(get_buffer): New function that allocates the requested buffer size.
Remove msc_vsnprintf(), vfmtconcat(), and fmtconcat() as unneeded.
* makeint.h: Declare various helper macros for generating output.
* *.c: Change all error(), fatal(), message() calls to use the macros,
or pass the extra length argument directly.
Diffstat (limited to 'remake.c')
-rw-r--r-- | remake.c | 72 |
1 files changed, 41 insertions, 31 deletions
@@ -228,10 +228,10 @@ update_goal_chain (struct dep *goals) && file->update_status == us_success && !g->changed /* Never give a message under -s or -q. */ && !silent_flag && !question_flag) - message (1, ((file->phony || file->cmds == 0) - ? _("Nothing to be done for '%s'.") - : _("'%s' is up to date.")), - file->name); + OS (message, 1, ((file->phony || file->cmds == 0) + ? _("Nothing to be done for '%s'.") + : _("'%s' is up to date.")), + file->name); /* This goal is finished. Remove it from the chain. */ if (lastgoal == 0) @@ -373,24 +373,30 @@ complain (struct file *file) if (d == 0) { - const char *msg_noparent - = _("%sNo rule to make target '%s'%s"); - const char *msg_parent - = _("%sNo rule to make target '%s', needed by '%s'%s"); - /* Didn't find any dependencies to complain about. */ - if (!keep_going_flag) + if (file->parent) { - if (file->parent == 0) - fatal (NILF, msg_noparent, "", file->name, ""); + size_t l = strlen (file->name) + strlen (file->parent->name) + 4; - fatal (NILF, msg_parent, "", file->name, file->parent->name, ""); - } + if (!keep_going_flag) + fatal (NILF, l, + _("%sNo rule to make target '%s', needed by '%s'%s"), + "", file->name, file->parent->name, ""); - if (file->parent == 0) - error (NILF, msg_noparent, "*** ", file->name, "."); + error (NILF, l, _("%sNo rule to make target '%s', needed by '%s'%s"), + "*** ", file->name, file->parent->name, "."); + } else - error (NILF, msg_parent, "*** ", file->name, file->parent->name, "."); + { + size_t l = strlen (file->name) + 4; + + if (!keep_going_flag) + fatal (NILF, l, + _("%sNo rule to make target '%s'%s"), "", file->name, ""); + + error (NILF, l, + _("%sNo rule to make target '%s'%s"), "*** ", file->name, "."); + } file->no_diag = 0; } @@ -478,8 +484,9 @@ update_file_1 (struct file *file, unsigned int depth) /* Avoid spurious rebuilds due to low resolution time stamps. */ int ns = FILE_TIMESTAMP_NS (this_mtime); if (ns != 0) - error (NILF, _("*** Warning: .LOW_RESOLUTION_TIME file '%s' has a high resolution time stamp"), - file->name); + OS (error, NILF, + _("*** Warning: .LOW_RESOLUTION_TIME file '%s' has a high resolution time stamp"), + file->name); this_mtime += FILE_TIMESTAMPS_PER_S - 1 - ns; } @@ -532,8 +539,8 @@ update_file_1 (struct file *file, unsigned int depth) if (is_updating (d->file)) { - error (NILF, _("Circular %s <- %s dependency dropped."), - file->name, d->file->name); + OSS (error, NILF, _("Circular %s <- %s dependency dropped."), + file->name, d->file->name); /* We cannot free D here because our the caller will still have a reference to it when we were called recursively via check_dep below. */ @@ -675,8 +682,8 @@ update_file_1 (struct file *file, unsigned int depth) if (depth == 0 && keep_going_flag && !just_print_flag && !question_flag) - error (NILF, - _("Target '%s' not remade because of errors."), file->name); + OS (error, NILF, + _("Target '%s' not remade because of errors."), file->name); return dep_status; } @@ -1064,8 +1071,8 @@ check_dep (struct file *file, unsigned int depth, if (is_updating (d->file)) { - error (NILF, _("Circular %s <- %s dependency dropped."), - file->name, d->file->name); + OSS (error, NILF, _("Circular %s <- %s dependency dropped."), + file->name, d->file->name); if (ld == 0) { file->deps = d->next; @@ -1122,7 +1129,7 @@ static enum update_status touch_file (struct file *file) { if (!silent_flag) - message (0, "touch %s", file->name); + OS (message, 0, "touch %s", file->name); /* Print-only (-n) takes precedence over touch (-t). */ if (just_print_flag) @@ -1369,8 +1376,9 @@ f_mtime (struct file *file, int search) if (adjusted_now < adjusted_mtime) { #ifdef NO_FLOAT - error (NILF, _("Warning: File '%s' has modification time in the future"), - file->name); + OS (error, NILF, + _("Warning: File '%s' has modification time in the future"), + file->name); #else double from_now = (FILE_TIMESTAMP_S (mtime) - FILE_TIMESTAMP_S (now) @@ -1382,8 +1390,9 @@ f_mtime (struct file *file, int search) sprintf (from_now_string, "%lu", (unsigned long) from_now); else sprintf (from_now_string, "%.2g", from_now); - error (NILF, _("Warning: File '%s' has modification time %s s in the future"), - file->name, from_now_string); + OSS (error, NILF, + _("Warning: File '%s' has modification time %s s in the future"), + file->name, from_now_string); #endif clock_skew_detected = 1; } @@ -1580,7 +1589,8 @@ library_search (const char *lib, FILE_TIMESTAMP *mtime_ptr) if (!p3) { /* Give a warning if there is no pattern. */ - error (NILF, _(".LIBPATTERNS element '%s' is not a pattern"), p); + OS (error, NILF, + _(".LIBPATTERNS element '%s' is not a pattern"), p); p[len] = c; continue; } |