#include "xalloc.h"
#include "widechar.h"
#include "strutils.h"
+#include "closestream.h"
#define BS '\b' /* backspace */
#define TAB '\t' /* tab */
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
max_bufd_lines = 128 * 2;
compress_spaces = 1; /* compress spaces into tabs */
/* missing a \n on the last line? */
nblank_lines = 2;
flush_blanks();
- if (ferror(stdout) || fclose(stdout))
- return EXIT_FAILURE;
return ret;
}
#include "widechar.h"
#include "c.h"
+#include "closestream.h"
int plus(wchar_t c, wchar_t d);
void move(int l, int m);
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
/* Take care of lonely hyphen option. */
for (i = 0; i < argc; i++)
fclose(f);
} while (argc > 0);
fflush(stdout);
- if (ferror(stdout) || fclose(stdout))
- return EXIT_FAILURE;
return EXIT_SUCCESS;
}
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
+#include <unistd.h>
#include "nls.h"
#include "widechar.h"
#include "strutils.h"
#include "c.h"
+#include "closestream.h"
/*
COLRM removes unwanted columns from a file
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
while ((opt =
getopt_long(argc, argv, "bfhl:pxVH", longopts,
;
fflush(stdout);
- if (ferror(stdout) || fclose(stdout))
- return EXIT_FAILURE;
return EXIT_SUCCESS;
}
#include "c.h"
#include "xalloc.h"
#include "strutils.h"
+#include "closestream.h"
#ifdef HAVE_WIDECHAR
#define wcs_width(s) wcswidth(s,wcslen(s))
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &win) == -1 || !win.ws_col) {
char *p;
free(list[i]);
free(list);
- if (ferror(stdout) || fclose(stdout))
- eval += EXIT_FAILURE;
-
if (eval == 0)
return EXIT_SUCCESS;
else
#include "nls.h"
#include "c.h"
+#include "closestream.h"
FS *fshead; /* head of format strings */
int blocksize; /* data block size */
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
if (!(p = strrchr(argv[0], 'o')) || strcmp(p, "od")) {
newsyntax(argc, &argv);
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/wait.h>
-#include "strutils.h"
+#include "strutils.h"
#include "nls.h"
#include "xalloc.h"
#include "widechar.h"
+#include "closestream.h"
#define _REGEX_RE_COMP
#include <regex.h>
void cleareol(void);
void clreos(void);
void home(void);
-void error (char *mess);
+void more_error (char *mess);
void do_shell (char *filename);
int colon (char *filename, int cmd, int nlines);
int expand (char **outbuf, char *inbuf);
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
nfiles = argc;
fnames = argv;
context.chrctr = startline;
lncount = 0;
if ((s = re_comp (buf)) != 0)
- error (s);
+ more_error (s);
while (!feof (file)) {
line3 = line2;
line2 = line1;
break;
}
} else if (rv == -1)
- error (_("Regular expression botch"));
+ more_error (_("Regular expression botch"));
}
if (feof (file)) {
if (!no_intty) {
putsout(_("\nPattern not found\n"));
end_it (0);
}
- error (_("Pattern not found"));
+ more_error (_("Pattern not found"));
}
}
*--sp = '\0';
if (!eraseln) promptlen = maxlen;
if (sp - buf >= nmax - 1)
- error (_("Line too long"));
+ more_error (_("Line too long"));
}
/* return: 0 - unchanged, 1 - changed, -1 - overflow (unchanged) */
break;
case '!':
if (!shellp)
- error (_("No previous command to substitute for"));
+ more_error (_("No previous command to substitute for"));
strcpy (outstr, shell_line);
outstr += strlen (shell_line);
changed++;
promptlen++;
}
-void error (char *mess)
+void more_error (char *mess)
{
if (clreol)
cleareol ();
#include "xalloc.h"
#include "widechar.h"
#include "writeall.h"
+#include "closestream.h"
#define READBUF LINE_MAX /* size of input buffer */
#define CMDBUF 255 /* size of command buffer */
setlocale(LC_MESSAGES, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
if (tcgetattr(1, &otio) == 0) {
ontty = 1;
#include "xalloc.h"
#include "widechar.h"
#include "c.h"
+#include "closestream.h"
wchar_t *buf;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
#include "usleep.h"
#include "strutils.h"
#include "c.h"
+#include "closestream.h"
#define DEFAULT_LINES 10
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
static const struct option longopts[] = {
{ "lines", required_argument, 0, 'n' },
#include "xalloc.h"
#include "widechar.h"
#include "c.h"
+#include "closestream.h"
#ifdef HAVE_WIDECHAR
/* Output an ASCII character as a wide character */
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
+ atexit(close_stdout);
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);
filter(f);
fclose(f);
}
- if (ferror(stdout) || fclose(stdout))
- return EXIT_FAILURE;
-
free(obuf);
return EXIT_SUCCESS;
}