Remove halt.c, improve comments, rename manual page file.
CFLAGS = -O $(XFLAGS)
LIBS =
-$(TARGET): entab.o halt.o
+$(TARGET): entab.o
$(CC) -o $@ $(CFLAGS) $^ $(LIBS)
clean:
-.\" src/tools/entab/entab.man
.TH ENTAB 1 local
.SH NAME
entab - tab processor
tab size set to the original tab size, then use entab to re-tab
the file with the new tab size.
.SH AUTHOR
-Bruce Momjian, root@candle.pha.pa.us
+Bruce Momjian, bruce@momjian.us
/*
-** entab.c - add tabs to a text file
-** by Bruce Momjian (root@candle.pha.pa.us)
-**
-** src/tools/entab/entab.c
-**
-** version 1.3
-**
-** tabsize = 4
-**
-*/
+ * entab.c - adds/removes tabs from text files
+ */
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PG_BINARY_R "r"
#endif
-#define NUL '\0'
+#define NUL '\0'
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
-void halt();
-
extern char *optarg;
extern int optind;
break;
case 'h':
case '?':
- halt("USAGE: %s [ -cdqst ] [file ...]\n\
+ fprintf(stderr, "USAGE: %s [ -cdqst ] [file ...]\n\
-c (clip trailing whitespace)\n\
-d (delete tabs)\n\
-q (protect quotes)\n\
-s minimum_spaces\n\
-t tab_width\n",
cp);
+ exit(0);
}
argv += optind;
else
{
if ((in_file = fopen(*argv, PG_BINARY_R)) == NULL)
- halt("PERROR: Cannot open file %s\n", argv[0]);
+ {
+ fprintf(stderr, "Cannot open file %s: %s\n", argv[0], strerror(errno));
+ exit(1);
+ }
argv++;
}
*(dst++) = ' ';
*dst = NUL;
if (fputs(out_line, stdout) == EOF)
- halt("PERROR: Error writing output.\n");
+ {
+ fprintf(stderr, "Cannot write to output file %s: %s\n", argv[0], strerror(errno));
+ exit(1);
+ }
}
} while (--argc > 0);
return 0;
+++ /dev/null
-/*
-**
-** halt.c
-**
-** src/tools/entab/halt.c
-**
-** This is used to print out error messages and exit
-*/
-
-#include <stdarg.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-
-/*-------------------------------------------------------------------------
-**
-** halt - print error message, and call clean up routine or exit
-**
-**------------------------------------------------------------------------*/
-
-/*VARARGS*/
-void
-halt(const char *format,...)
-{
- va_list arg_ptr;
- const char *pstr;
- void (*sig_func) ();
-
- va_start(arg_ptr, format);
- if (strncmp(format, "PERROR", 6) != 0)
- vfprintf(stderr, format, arg_ptr);
- else
- {
- for (pstr = format + 6; *pstr == ' ' || *pstr == ':'; pstr++)
- ;
- vfprintf(stderr, pstr, arg_ptr);
- perror("");
- }
- va_end(arg_ptr);
- fflush(stderr);
-
- /* call one clean up function if defined */
- if ((sig_func = signal(SIGTERM, SIG_DFL)) != SIG_DFL &&
- sig_func != SIG_IGN)
- (*sig_func) (0);
- else if ((sig_func = signal(SIGHUP, SIG_DFL)) != SIG_DFL &&
- sig_func != SIG_IGN)
- (*sig_func) (0);
- else if ((sig_func = signal(SIGINT, SIG_DFL)) != SIG_DFL &&
- sig_func != SIG_IGN)
- (*sig_func) (0);
- else if ((sig_func = signal(SIGQUIT, SIG_DFL)) != SIG_DFL &&
- sig_func != SIG_IGN)
- (*sig_func) (0);
- exit(1);
-}