Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf979599

Browse files
committed
Modernize entab source code
Remove halt.c, improve comments, rename manual page file.
1 parent8791627 commitf979599

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.manrenamed 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
#definePG_BINARY_R "r"
2316
#endif
2417

25-
#defineNUL'\0'
18+
#defineNUL'\0'
2619

2720
#ifndefTRUE
2821
#defineTRUE1
@@ -31,8 +24,6 @@
3124
#defineFALSE0
3225
#endif
3326

34-
voidhalt();
35-
3627
externchar*optarg;
3728
externintoptind;
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
return0;

‎src/tools/entab/halt.c

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp