Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
f979599b
Commit
f979599b
authored
Jun 19, 2013
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modernize entab source code
Remove halt.c, improve comments, rename manual page file.
parent
8791627b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
78 deletions
+16
-78
src/tools/entab/Makefile
src/tools/entab/Makefile
+1
-1
src/tools/entab/entab.1
src/tools/entab/entab.1
+1
-2
src/tools/entab/entab.c
src/tools/entab/entab.c
+14
-16
src/tools/entab/halt.c
src/tools/entab/halt.c
+0
-59
No files found.
src/tools/entab/Makefile
View file @
f979599b
...
...
@@ -8,7 +8,7 @@ XFLAGS =
CFLAGS
=
-O
$(XFLAGS)
LIBS
=
$(TARGET)
:
entab.o
halt.o
$(TARGET)
:
entab.o
$(CC)
-o
$@
$(CFLAGS)
$^
$(LIBS)
clean
:
...
...
src/tools/entab/entab.
man
→
src/tools/entab/entab.
1
View file @
f979599b
.\" src/tools/entab/entab.man
.TH ENTAB 1 local
.SH NAME
entab - tab processor
...
...
@@ -49,4 +48,4 @@ use detab (or entab -d) to remove tabs from the file with the
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
src/tools/entab/entab.c
View file @
f979599b
/*
** 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>
...
...
@@ -22,7 +15,7 @@
#define PG_BINARY_R "r"
#endif
#define NUL
'\0'
#define NUL '\0'
#ifndef TRUE
#define TRUE 1
...
...
@@ -31,8 +24,6 @@
#define FALSE 0
#endif
void
halt
();
extern
char
*
optarg
;
extern
int
optind
;
...
...
@@ -84,13 +75,14 @@ main(int argc, char **argv)
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
;
...
...
@@ -103,7 +95,10 @@ main(int argc, char **argv)
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
++
;
}
...
...
@@ -219,7 +214,10 @@ main(int argc, char **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
;
...
...
src/tools/entab/halt.c
deleted
100644 → 0
View file @
8791627b
/*
**
** 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
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment