Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f979599

Browse files
committed
Modernize entab source code
Remove halt.c, improve comments, rename manual page file.
1 parent 8791627 commit f979599

File tree

4 files changed

+16
-78
lines changed

4 files changed

+16
-78
lines changed

src/tools/entab/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ XFLAGS =
88
CFLAGS = -O $(XFLAGS)
99
LIBS =
1010

11-
$(TARGET): entab.o halt.o
11+
$(TARGET): entab.o
1212
$(CC) -o $@ $(CFLAGS) $^ $(LIBS)
1313

1414
clean:

src/tools/entab/entab.man renamed to src/tools/entab/entab.1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.\" src/tools/entab/entab.man
21
.TH ENTAB 1 local
32
.SH NAME
43
entab - tab processor
@@ -49,4 +48,4 @@ use detab (or entab -d) to remove tabs from the file with the
4948
tab size set to the original tab size, then use entab to re-tab
5049
the file with the new tab size.
5150
.SH AUTHOR
52-
Bruce Momjian, root@candle.pha.pa.us
51+
Bruce Momjian, bruce@momjian.us

src/tools/entab/entab.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
/*
2-
** entab.c - add tabs to a text file
3-
** by Bruce Momjian (root@candle.pha.pa.us)
4-
**
5-
** src/tools/entab/entab.c
6-
**
7-
** version 1.3
8-
**
9-
** tabsize = 4
10-
**
11-
*/
2+
* entab.c - adds/removes tabs from text files
3+
*/
124

5+
#include <errno.h>
136
#include <stdio.h>
147
#include <stdlib.h>
158
#include <string.h>
@@ -22,7 +15,7 @@
2215
#define PG_BINARY_R "r"
2316
#endif
2417

25-
#define NUL '\0'
18+
#define NUL '\0'
2619

2720
#ifndef TRUE
2821
#define TRUE 1
@@ -31,8 +24,6 @@
3124
#define FALSE 0
3225
#endif
3326

34-
void halt();
35-
3627
extern char *optarg;
3728
extern int optind;
3829

@@ -84,13 +75,14 @@ main(int argc, char **argv)
8475
break;
8576
case 'h':
8677
case '?':
87-
halt("USAGE: %s [ -cdqst ] [file ...]\n\
78+
fprintf(stderr, "USAGE: %s [ -cdqst ] [file ...]\n\
8879
-c (clip trailing whitespace)\n\
8980
-d (delete tabs)\n\
9081
-q (protect quotes)\n\
9182
-s minimum_spaces\n\
9283
-t tab_width\n",
9384
cp);
85+
exit(0);
9486
}
9587

9688
argv += optind;
@@ -103,7 +95,10 @@ main(int argc, char **argv)
10395
else
10496
{
10597
if ((in_file = fopen(*argv, PG_BINARY_R)) == NULL)
106-
halt("PERROR: Cannot open file %s\n", argv[0]);
98+
{
99+
fprintf(stderr, "Cannot open file %s: %s\n", argv[0], strerror(errno));
100+
exit(1);
101+
}
107102
argv++;
108103
}
109104

@@ -219,7 +214,10 @@ main(int argc, char **argv)
219214
*(dst++) = ' ';
220215
*dst = NUL;
221216
if (fputs(out_line, stdout) == EOF)
222-
halt("PERROR: Error writing output.\n");
217+
{
218+
fprintf(stderr, "Cannot write to output file %s: %s\n", argv[0], strerror(errno));
219+
exit(1);
220+
}
223221
}
224222
} while (--argc > 0);
225223
return 0;

src/tools/entab/halt.c

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)