aboutsummaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-01-18 02:57:08 +0000
committerMatt Kraai <kraai@debian.org>2001-01-18 02:57:08 +0000
commit12f417edbd21b322a8eaa8feb0ab238f13fa83c6 (patch)
tree06f9de2e4c7d33d29a448fb1c42ed1beafe18e6e /procps
parentc9acf8c766a9a2cc00449db5dea506d7663ad26b (diff)
downloadbusybox-12f417edbd21b322a8eaa8feb0ab238f13fa83c6.tar.gz
Eliminate calls of the form "fprintf(stdout,". Thanks for the idea to
Vladimir N. Oleynik.
Diffstat (limited to 'procps')
-rw-r--r--procps/ps.c19
-rw-r--r--procps/uptime.c8
2 files changed, 12 insertions, 15 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 2b41a495f..ec63bb548 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -143,8 +143,7 @@ extern int ps_main(int argc, char **argv)
terminal_width = win.ws_col - 1;
#endif
- fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid",
- "State", "Command");
+ printf("%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", "State", "Command");
while ((entry = readdir(dir)) != NULL) {
if (!isdigit(*entry->d_name))
continue;
@@ -166,8 +165,7 @@ extern int ps_main(int argc, char **argv)
if (file == NULL)
continue;
i = 0;
- len = fprintf(stdout, "%5d %-8s %-8s %c ", p.pid, uidName, groupName,
- p.state);
+ len = printf("%5d %-8s %-8s %c ", p.pid, uidName, groupName, p.state);
while (((c = getc(file)) != EOF) && (i < (terminal_width-len))) {
i++;
if (c == '\0')
@@ -176,8 +174,8 @@ extern int ps_main(int argc, char **argv)
}
fclose(file);
if (i == 0)
- fprintf(stdout, "[%s]", p.cmd);
- fprintf(stdout, "\n");
+ printf("[%s]", p.cmd);
+ putchar('\n');
}
closedir(dir);
return EXIT_SUCCESS;
@@ -240,8 +238,7 @@ extern int ps_main(int argc, char **argv)
#endif
/* Print up a ps listing */
- fprintf(stdout, "%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid",
- "State", "Command");
+ printf("%5s %-8s %-3s %5s %s\n", "PID", "Uid", "Gid", "State", "Command");
for (i=1; i<pid_array[0] ; i++) {
info.pid = pid_array[i];
@@ -257,7 +254,7 @@ extern int ps_main(int argc, char **argv)
if (*groupName == '\0')
sprintf(groupName, "%ld", info.egid);
- len = fprintf(stdout, "%5d %-8s %-8s %c ", info.pid, uidName, groupName, info.state);
+ len = printf("%5d %-8s %-8s %c ", info.pid, uidName, groupName, info.state);
if (strlen(info.command_line) > 1) {
for( j=0; j<(sizeof(info.command_line)-1) && j < (terminal_width-len); j++) {
@@ -266,9 +263,9 @@ extern int ps_main(int argc, char **argv)
}
}
*(info.command_line+j) = '\0';
- fprintf(stdout, "%s\n", info.command_line);
+ puts(info.command_line);
} else {
- fprintf(stdout, "[%s]\n", info.name);
+ printf("[%s]\n", info.name);
}
}
diff --git a/procps/uptime.c b/procps/uptime.c
index 159f24baa..fb3d347c3 100644
--- a/procps/uptime.c
+++ b/procps/uptime.c
@@ -51,19 +51,19 @@ extern int uptime_main(int argc, char **argv)
sysinfo(&info);
- fprintf(stdout, " %2d:%02d%s up ",
+ printf(" %2d:%02d%s up ",
current_time->tm_hour%12 ? current_time->tm_hour%12 : 12,
current_time->tm_min, current_time->tm_hour > 11 ? "pm" : "am");
updays = (int) info.uptime / (60*60*24);
if (updays)
- fprintf(stdout, "%d day%s, ", updays, (updays != 1) ? "s" : "");
+ printf("%d day%s, ", updays, (updays != 1) ? "s" : "");
upminutes = (int) info.uptime / 60;
uphours = (upminutes / 60) % 24;
upminutes %= 60;
if(uphours)
- fprintf(stdout, "%2d:%02d, ", uphours, upminutes);
+ printf("%2d:%02d, ", uphours, upminutes);
else
- fprintf(stdout, "%d min, ", upminutes);
+ printf("%d min, ", upminutes);
printf("load average: %ld.%02ld, %ld.%02ld, %ld.%02ld\n",
LOAD_INT(info.loads[0]), LOAD_FRAC(info.loads[0]),