src/bin/psql/command.c
static int
strip_lineno_from_objdesc(char *obj)
{
	char	   *c;
	int			lineno;

	if (!obj || obj[0] == '\0')
		return -1;

	c = obj + strlen(obj) - 1;

	/*
	 * This business of parsing backwards is dangerous as can be in a
	 * multibyte environment: there is no reason to believe that we are
	 * looking at the first byte of a character, nor are we necessarily
	 * working in a "safe" encoding.  Fortunately the bitpatterns we are
	 * looking for are unlikely to occur as non-first bytes, but beware of
	 * trying to expand the set of cases that can be recognized.  We must
	 * guard the <ctype.h> macros by using isascii() first, too.
	 */

	/* skip trailing whitespace */
	while (c > obj && isascii((unsigned char) *c) && isspace((unsigned char) *c))
		c--;

	/* must have a digit as last non-space char */
	if (c == obj || !isascii((unsigned char) *c) || !isdigit((unsigned char) *c))
		return -1;

	/* find start of digit string */
	while (c > obj && isascii((unsigned char) *c) && isdigit((unsigned char) *c))
		c--;

	/* digits must be separated from object name by space or closing paren */
	/* notice also that we are not allowing an empty object name ... */
	if (c == obj || !isascii((unsigned char) *c) ||
		!(isspace((unsigned char) *c) || *c == ')'))
		return -1;

	/* parse digit string */
	c++;
	lineno = atoi(c);
	if (lineno < 1)
	{
		pg_log_error("invalid line number: %s", c);
		return 0;
	}

	/* strip digit string from object name */
	*c = '\0';

	return lineno;
}
/*
 * If the given argument of \ef or \ev ends with a line number, delete the line
 * number from the argument string and return it as an integer.  (We need
 * this kluge because we're too lazy to parse \ef's function or \ev's view
 * argument carefully --- we just slop it up in OT_WHOLE_LINE mode.)
 *
 * Returns -1 if no line number is present, 0 on error, or a positive value
 * on success.
 */
If the given argument of \ef or \ev ends with a line number, delete the line
number from the argument string and return it as an integer.  (We need
this kluge because we're too lazy to parse \ef's function or \ev's view
argument carefully --- we just slop it up in OT_WHOLE_LINE mode.)

1 if no line number is present, 0 on error, or a positive value
on success.
If the given argument of \ ef or \ ev ends with a line number delete the line number from the argument string and return it as an integer . ( We need this kluge because we ' re too lazy to parse \ ef ' s function or \ ev ' s view argument carefully --- we just slop it up in OT_WHOLE_LINE mode . ) 1 if no line number is present 0 on error or a positive value on success .
static int
strip_lineno_from_objdesc(char *obj)
{
	char	   *c;
	int			lineno;
	if (!obj || obj[0] == '\0')
		return -1;
	c = obj + strlen(obj) - 1;
	while (c > obj && isascii((unsigned char) *c) && isspace((unsigned char) *c))
		c--;
	if (c == obj || !isascii((unsigned char) *c) || !isdigit((unsigned char) *c))
		return -1;
	while (c > obj && isascii((unsigned char) *c) && isdigit((unsigned char) *c))
		c--;
	if (c == obj || !isascii((unsigned char) *c) ||
		!(isspace((unsigned char) *c) || *c == ')'))
		return -1;
	c++;
	lineno = atoi(c);
	if (lineno < 1)
	{
		pg_log_error("invalid line number: %s", c);
		return 0;
	}
	*c = '\0';
	return lineno;
}
static int strip_lineno_from_objdesc ( char * obj ) { char * c ; int lineno ; if ( ! obj || obj [ 0 ] == ' \0 ' ) return -1 ; c = obj + strlen ( obj ) - 1 ; while ( c > obj && isascii ( ( unsigned char ) * c ) && isspace ( ( unsigned char ) * c ) ) c -- ; if ( c == obj || ! isascii ( ( unsigned char ) * c ) || ! isdigit ( ( unsigned char ) * c ) ) return -1 ; while ( c > obj && isascii ( ( unsigned char ) * c ) && isdigit ( ( unsigned char ) * c ) ) c -- ; if ( c == obj || ! isascii ( ( unsigned char ) * c ) || ! ( isspace ( ( unsigned char ) * c ) || * c == ' ' ) ) return -1 ; c ++ ; lineno = atoi ( c ) ; if ( lineno < 1 ) { pg_log_error ( " " , c ) ; return 0 ; } * c = ' \0 ' ; return lineno ; }
If the given argument of \ef or \ev ends with a line number, delete the line
 number from the argument string and return it as an integer.
If the given argument of \ ef or \ ev ends with a line number delete the line number from the argument string and return it as an integer .
/*
	 * This business of parsing backwards is dangerous as can be in a
	 * multibyte environment: there is no reason to believe that we are
	 * looking at the first byte of a character, nor are we necessarily
	 * working in a "safe" encoding.  Fortunately the bitpatterns we are
	 * looking for are unlikely to occur as non-first bytes, but beware of
	 * trying to expand the set of cases that can be recognized.  We must
	 * guard the <ctype.h> macros by using isascii() first, too.
	 */ /* skip trailing whitespace */ /* must have a digit as last non-space char */ /* find start of digit string */ /* digits must be separated from object name by space or closing paren */ /* notice also that we are not allowing an empty object name ... */ /* parse digit string */ /* strip digit string from object name */