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

Commit3d9b6f3

Browse files
committed
Minor code beautification in conninfo_uri_parse_params().
Reading this made me itch, so clean the logic a bit.
1 parentb26e208 commit3d9b6f3

File tree

1 file changed

+19
-36
lines changed

1 file changed

+19
-36
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 19 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4934,36 +4934,30 @@ conninfo_uri_parse_params(char *params,
49344934
{
49354935
printfPQExpBuffer(errorMessage,
49364936
libpq_gettext("extra key/value separator \"=\" in URI query parameter: \"%s\"\n"),
4937-
params);
4937+
keyword);
49384938
return false;
49394939
}
49404940
/* Cut off keyword, advance to value */
4941-
*p='\0';
4942-
value=++p;
4941+
*p++='\0';
4942+
value=p;
49434943
}
49444944
elseif (*p=='&'||*p=='\0')
49454945
{
4946-
charprevchar;
4947-
4948-
/* Cut off value, remember old value */
4949-
prevchar=*p;
4950-
*p='\0';
4951-
4946+
/*
4947+
* If not at the end, cut off value and advance; leave p
4948+
* pointing to start of the next parameter, if any.
4949+
*/
4950+
if (*p!='\0')
4951+
*p++='\0';
49524952
/* Was there '=' at all? */
49534953
if (value==NULL)
49544954
{
49554955
printfPQExpBuffer(errorMessage,
49564956
libpq_gettext("missing key/value separator \"=\" in URI query parameter: \"%s\"\n"),
4957-
params);
4957+
keyword);
49584958
return false;
49594959
}
4960-
4961-
/*
4962-
* If not at the end, advance; now pointing to start of the
4963-
* next parameter, if any.
4964-
*/
4965-
if (prevchar!='\0')
4966-
++p;
4960+
/* Got keyword and value, go process them. */
49674961
break;
49684962
}
49694963
else
@@ -5007,38 +5001,27 @@ conninfo_uri_parse_params(char *params,
50075001
if (!conninfo_storeval(connOptions,keyword,value,
50085002
errorMessage, true, false))
50095003
{
5010-
/*
5011-
* Check if there was a hard error when decoding or storing the
5012-
* option.
5013-
*/
5014-
if (errorMessage->len!=0)
5015-
{
5016-
if (malloced)
5017-
{
5018-
free(keyword);
5019-
free(value);
5020-
}
5021-
return false;
5022-
}
5023-
5024-
printfPQExpBuffer(errorMessage,
5025-
libpq_gettext(
5026-
"invalid URI query parameter: \"%s\"\n"),
5027-
keyword);
5004+
/* Insert generic message if conninfo_storeval didn't give one. */
5005+
if (errorMessage->len==0)
5006+
printfPQExpBuffer(errorMessage,
5007+
libpq_gettext("invalid URI query parameter: \"%s\"\n"),
5008+
keyword);
5009+
/* And fail. */
50285010
if (malloced)
50295011
{
50305012
free(keyword);
50315013
free(value);
50325014
}
50335015
return false;
50345016
}
5017+
50355018
if (malloced)
50365019
{
50375020
free(keyword);
50385021
free(value);
50395022
}
50405023

5041-
/* Proceed to next key=value pair */
5024+
/* Proceed to next key=value pair, if any */
50425025
params=p;
50435026
}
50445027

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp