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
e185583a
Commit
e185583a
authored
May 27, 2003
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow input from stdin and output to stdout.
parent
67784456
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
44 deletions
+59
-44
src/interfaces/ecpg/ChangeLog
src/interfaces/ecpg/ChangeLog
+4
-0
src/interfaces/ecpg/preproc/ecpg.c
src/interfaces/ecpg/preproc/ecpg.c
+54
-35
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/pgc.l
+1
-9
No files found.
src/interfaces/ecpg/ChangeLog
View file @
e185583a
...
...
@@ -1445,6 +1445,10 @@ Fri May 23 11:46:15 CEST 2003
Tue May 27 13:29:28 CEST 2003
- Fixed incorrect output for some structs.
Tue May 27 16:33:36 CEST 2003
- Accept stdin/stdout as input/output file.
- Set ecpg version to 2.12.0.
- Set ecpg library to 3.4.2.
- Set pgtypes library to 1.0.0
...
...
src/interfaces/ecpg/preproc/ecpg.c
View file @
e185583a
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.7
0 2003/05/14 14:37:35
meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/ecpg.c,v 1.7
1 2003/05/27 14:36:00
meskes Exp $ */
/* New main for ecpg, the PostgreSQL embedded SQL precompiler. */
/* (C) Michael Meskes <meskes@postgresql.org> Feb 5th, 1998 */
...
...
@@ -137,7 +137,11 @@ main(int argc, char *const argv[])
switch
(
c
)
{
case
'o'
:
yyout
=
fopen
(
optarg
,
PG_BINARY_W
);
if
(
strcmp
(
optarg
,
"-"
)
==
0
)
yyout
=
stdout
;
else
yyout
=
fopen
(
optarg
,
PG_BINARY_W
);
if
(
yyout
==
NULL
)
perror
(
optarg
);
else
...
...
@@ -219,47 +223,62 @@ main(int argc, char *const argv[])
char
*
output_filename
=
NULL
,
*
ptr2ext
;
input_filename
=
mm_alloc
(
strlen
(
argv
[
fnr
])
+
5
);
strcpy
(
input_filename
,
argv
[
fnr
]);
/* If argv[fnr] is "-" we have to read from stdin */
if
(
strcmp
(
argv
[
fnr
],
"-"
)
==
0
)
{
input_filename
=
mm_alloc
(
strlen
(
"stdin"
)
+
1
);
strcpy
(
input_filename
,
"stdin"
);
yyin
=
stdin
;
}
else
{
input_filename
=
mm_alloc
(
strlen
(
argv
[
fnr
])
+
5
);
strcpy
(
input_filename
,
argv
[
fnr
]);
/* take care of relative paths */
ptr2ext
=
last_path_separator
(
input_filename
);
ptr2ext
=
(
ptr2ext
?
strrchr
(
ptr2ext
,
'.'
)
:
strrchr
(
input_filename
,
'.'
));
/* take care of relative paths */
ptr2ext
=
last_path_separator
(
input_filename
);
ptr2ext
=
(
ptr2ext
?
strrchr
(
ptr2ext
,
'.'
)
:
strrchr
(
input_filename
,
'.'
));
/* no extension? */
if
(
ptr2ext
==
NULL
)
{
ptr2ext
=
input_filename
+
strlen
(
input_filename
);
/* no extension => add .pgc */
ptr2ext
[
0
]
=
'.'
;
ptr2ext
[
1
]
=
'p'
;
ptr2ext
[
2
]
=
'g'
;
ptr2ext
[
3
]
=
'c'
;
ptr2ext
[
4
]
=
'\0'
;
/* no extension? */
if
(
ptr2ext
==
NULL
)
{
ptr2ext
=
input_filename
+
strlen
(
input_filename
);
/* no extension => add .pgc */
ptr2ext
[
0
]
=
'.'
;
ptr2ext
[
1
]
=
'p'
;
ptr2ext
[
2
]
=
'g'
;
ptr2ext
[
3
]
=
'c'
;
ptr2ext
[
4
]
=
'\0'
;
}
yyin
=
fopen
(
input_filename
,
PG_BINARY_R
);
}
if
(
out_option
==
0
)
/* calculate the output name */
{
output_filename
=
strdup
(
input_filename
);
if
(
strcmp
(
input_filename
,
"stdin"
)
==
0
)
yyout
=
stdout
;
else
{
output_filename
=
strdup
(
input_filename
);
ptr2ext
=
strrchr
(
output_filename
,
'.'
);
/* make extension = .c */
ptr2ext
[
1
]
=
'c'
;
ptr2ext
[
2
]
=
'\0'
;
ptr2ext
=
strrchr
(
output_filename
,
'.'
);
/* make extension = .c */
ptr2ext
[
1
]
=
'c'
;
ptr2ext
[
2
]
=
'\0'
;
yyout
=
fopen
(
output_filename
,
PG_BINARY_W
);
if
(
yyout
==
NULL
)
{
perror
(
output_filename
);
free
(
output_filename
);
free
(
input_filename
);
continue
;
yyout
=
fopen
(
output_filename
,
PG_BINARY_W
);
if
(
yyout
==
NULL
)
{
perror
(
output_filename
);
free
(
output_filename
);
free
(
input_filename
);
continue
;
}
}
}
yyin
=
fopen
(
input_filename
,
PG_BINARY_R
);
if
(
yyin
==
NULL
)
perror
(
argv
[
fnr
]);
else
...
...
@@ -341,7 +360,7 @@ main(int argc, char *const argv[])
/* finally the actual connection */
connection
=
NULL
;
/* initialize lex */
lex_init
();
...
...
@@ -355,9 +374,9 @@ main(int argc, char *const argv[])
/* and parse the source */
yyparse
();
if
(
yyin
!=
NULL
)
if
(
yyin
!=
NULL
&&
yyin
!=
stdin
)
fclose
(
yyin
);
if
(
out_option
==
0
)
if
(
out_option
==
0
&&
yyout
!=
stdout
)
fclose
(
yyout
);
}
...
...
src/interfaces/ecpg/preproc/pgc.l
View file @
e185583a
...
...
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.11
0 2003/05/22 07:58:41
meskes Exp $
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.11
1 2003/05/27 14:36:00
meskes Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -399,14 +399,6 @@ cppline {space}*#(.*\\{space})+.*
BEGIN(state_before);
if (literallen == 0)
mmerror(PARSE_ERROR, ET_ERROR, "zero-length delimited identifier");
if (literallen >= NAMEDATALEN)
{
snprintf(errortext, sizeof(errortext), "identifier \"%s\" will be truncated to \"%.*s\"",
literalbuf, NAMEDATALEN-1, literalbuf);
literalbuf[NAMEDATALEN-1] = '\0';
mmerror(PARSE_ERROR, ET_WARNING, errortext);
}
yylval.str = mm_strdup(literalbuf);
return CSTRING;
}
...
...
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