summaryrefslogtreecommitdiffstats
path: root/misc-utils
diff options
context:
space:
mode:
Diffstat (limited to 'misc-utils')
-rw-r--r--misc-utils/script.c22
-rw-r--r--misc-utils/setterm.c27
2 files changed, 38 insertions, 11 deletions
diff --git a/misc-utils/script.c b/misc-utils/script.c
index a5d0c6637..ec98ea1a4 100644
--- a/misc-utils/script.c
+++ b/misc-utils/script.c
@@ -238,6 +238,15 @@ resize(int dummy) {
kill(child, SIGWINCH);
}
+/*
+ * Stop extremely silly gcc complaint on %c:
+ * warning: `%c' yields only last 2 digits of year in some locales
+ */
+static void
+my_strftime(char *buf, size_t len, const char *fmt, const struct tm *tm) {
+ strftime(buf, len, fmt, tm);
+}
+
void
dooutput() {
register int cc;
@@ -251,7 +260,9 @@ dooutput() {
(void) close(slave);
#endif
tvec = time((time_t *)NULL);
- fprintf(fscript, _("Script started on %s"), ctime(&tvec));
+ my_strftime(obuf, sizeof obuf, "%c\n", localtime(&tvec));
+ fprintf(fscript, _("Script started on %s"), obuf);
+
for (;;) {
if (tflg)
gettimeofday(&tv, NULL);
@@ -259,9 +270,9 @@ dooutput() {
if (cc <= 0)
break;
if (tflg) {
- newtime=tv.tv_sec + (double) tv.tv_usec / 1000000;
+ newtime = tv.tv_sec + (double) tv.tv_usec / 1000000;
fprintf(stderr, "%f %i\n", newtime - oldtime, cc);
- oldtime=newtime;
+ oldtime = newtime;
}
(void) write(1, obuf, cc);
(void) fwrite(obuf, 1, cc, fscript);
@@ -321,9 +332,10 @@ done() {
if (subchild) {
if (!qflg) {
+ char buf[BUFSIZ];
tvec = time((time_t *)NULL);
- fprintf(fscript, _("\nScript done on %s"),
- ctime(&tvec));
+ my_strftime(buf, sizeof buf, "%c\n", localtime(&tvec));
+ fprintf(fscript, _("\nScript done on %s"), buf);
}
(void) fclose(fscript);
(void) close(master);
diff --git a/misc-utils/setterm.c b/misc-utils/setterm.c
index 24fb90d83..7d1057217 100644
--- a/misc-utils/setterm.c
+++ b/misc-utils/setterm.c
@@ -107,6 +107,7 @@
#else
#include <curses.h>
#endif
+#include <sys/param.h> /* for MAXPATHLEN */
#include <sys/ioctl.h>
#include <sys/time.h>
#include "nls.h"
@@ -184,7 +185,7 @@ int opt_cl_all; /* Clear all or rest. */
int opt_bl_min; /* Blank screen. */
int opt_blength_l;
int opt_bfreq_f;
-int opt_sn_num = 0; /* Snap screen. */
+int opt_sn_num; /* Snap screen. */
int opt_st_attr;
int opt_rt_len; /* regular tab length */
int opt_tb_array[161]; /* Array for tab list */
@@ -1109,7 +1110,6 @@ perform_sequence(int vcterm) {
static void
screendump(int vcnum, FILE *F) {
-#include <sys/param.h>
char infile[MAXPATHLEN];
unsigned char header[4];
unsigned int rows, cols;
@@ -1117,13 +1117,28 @@ screendump(int vcnum, FILE *F) {
char *inbuf, *outbuf, *p, *q;
sprintf(infile, "/dev/vcsa%d", vcnum);
- fd = open(infile, 0);
- if (fd < 0 || read(fd, header, 4) != 4)
- goto try_ioctl;
+ fd = open(infile, O_RDONLY);
+ if (fd < 0 && vcnum == 0) {
+ /* vcsa0 is often called vcsa */
+ sprintf(infile, "/dev/vcsa");
+ fd = open(infile, O_RDONLY);
+ }
+ if (fd < 0) {
+ /* try devfs name - for zero vcnum just /dev/vcc/a */
+ /* some gcc's warn for %.u - add 0 */
+ sprintf(infile, "/dev/vcc/a%.0u", vcnum);
+ fd = open(infile, O_RDONLY);
+ }
+ if (fd < 0) {
+ sprintf(infile, "/dev/vcsa%d", vcnum);
+ goto try_ioctl;
+ }
+ if (read(fd, header, 4) != 4)
+ goto try_ioctl;
rows = header[0];
cols = header[1];
if (rows * cols == 0)
- goto try_ioctl;
+ goto try_ioctl;
inbuf = malloc(rows*cols*2);
outbuf = malloc(rows*(cols+1));
if(!inbuf || !outbuf) {