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
bd422fbc
Commit
bd422fbc
authored
Feb 07, 1999
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify scanstr(), fix broken octal-escape code.
parent
f7c6a88c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
71 deletions
+50
-71
src/backend/parser/scansup.c
src/backend/parser/scansup.c
+50
-71
No files found.
src/backend/parser/scansup.c
View file @
bd422fbc
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.1
0 1998/02/26 04:33:49 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.1
1 1999/02/07 23:59:59 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -29,12 +29,8 @@
* if the string passed in has escaped codes, map the escape codes to actual
* chars
*
* also, remove leading and ending quotes '"' if any
*
* the string passed in must be non-null
*
* the string returned is a pointer to static storage and should NOT
* be freed by the
CALLER
.
* be freed by the
caller
.
* ----------------
*/
...
...
@@ -55,76 +51,59 @@ scanstr(char *s)
{
if
(
s
[
i
]
==
'\''
)
{
i
=
i
+
1
;
if
(
s
[
i
]
==
'\''
)
newStr
[
j
]
=
'\''
;
/* Note: if scanner is working right, unescaped quotes can only
* appear in pairs, so there should be another character.
*/
i
++
;
newStr
[
j
]
=
s
[
i
];
}
else
else
if
(
s
[
i
]
==
'\\'
)
{
if
(
s
[
i
]
==
'\\'
)
i
++
;
switch
(
s
[
i
])
{
i
=
i
+
1
;
switch
(
s
[
i
])
{
case
'\\'
:
newStr
[
j
]
=
'\\'
;
break
;
case
'b'
:
newStr
[
j
]
=
'\b'
;
break
;
case
'f'
:
newStr
[
j
]
=
'\f'
;
break
;
case
'n'
:
newStr
[
j
]
=
'\n'
;
break
;
case
'r'
:
newStr
[
j
]
=
'\r'
;
break
;
case
't'
:
newStr
[
j
]
=
'\t'
;
break
;
case
'"'
:
newStr
[
j
]
=
'"'
;
break
;
case
'\''
:
newStr
[
j
]
=
'\''
;
break
;
case
'0'
:
case
'1'
:
case
'2'
:
case
'3'
:
case
'4'
:
case
'5'
:
case
'6'
:
case
'7'
:
{
char
octal
[
4
];
int
k
;
long
octVal
;
case
'b'
:
newStr
[
j
]
=
'\b'
;
break
;
case
'f'
:
newStr
[
j
]
=
'\f'
;
break
;
case
'n'
:
newStr
[
j
]
=
'\n'
;
break
;
case
'r'
:
newStr
[
j
]
=
'\r'
;
break
;
case
't'
:
newStr
[
j
]
=
'\t'
;
break
;
case
'0'
:
case
'1'
:
case
'2'
:
case
'3'
:
case
'4'
:
case
'5'
:
case
'6'
:
case
'7'
:
{
int
k
;
long
octVal
=
0
;
for
(
k
=
0
;
for
(
k
=
0
;
s
[
i
+
k
]
>=
'0'
&&
s
[
i
+
k
]
<=
'7'
&&
k
<
3
;
k
++
)
octal
[
k
]
=
s
[
i
+
k
];
i
+=
k
-
1
;
octal
[
3
]
=
'\0'
;
octVal
=
strtol
(
octal
,
0
,
8
);
/* elog (NOTICE, "octal = %s octVal = %d, %od", octal, octVal, octVal);*/
if
(
octVal
<=
0377
)
{
newStr
[
j
]
=
((
char
)
octVal
);
break
;
}
}
default:
newStr
[
j
]
=
s
[
i
];
}
/* switch */
}
/* s[i] == '\\' */
else
newStr
[
j
]
=
s
[
i
];
}
k
++
)
octVal
=
(
octVal
<<
3
)
+
(
s
[
i
+
k
]
-
'0'
);
i
+=
k
-
1
;
newStr
[
j
]
=
((
char
)
octVal
);
}
break
;
default:
newStr
[
j
]
=
s
[
i
];
break
;
}
/* switch */
}
/* s[i] == '\\' */
else
newStr
[
j
]
=
s
[
i
];
j
++
;
}
newStr
[
j
]
=
'\0'
;
...
...
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