Fix doc for initcap

Поиск
Список
Период
Сортировка
Искать

Fix doc for initcap

От:
Dennis Bjorklund <db@zigo.dhs.org>
Дата:
Вложения:
Here is a small doc patch that says that initcap lowercases the rest of
the characters in the string. The current doc suggests that it only
touches the first character in each word, which is not what the function
does.

Maybe we should change the example to be 'hi THOMAS' instead of 'hi 
thomas'.

Is it okay for me to commit this?

-- 
/Dennis Björklund

Re: Fix doc for initcap

От:
Neil Conway <neilc@samurai.com>
Дата:
Dennis Bjorklund  writes:
> Here is a small doc patch that says that initcap lowercases the rest
> of the characters in the string. The current doc suggests that it
> only touches the first character in each word, which is not what the
> function does.

The improved text is still wrong: initcap() no longer uses whitespace
to separate words. I've applied the attached patch to CVS HEAD, which
fixes this properly and makes some other doc cleanups.

Thanks for the patch!

-Neil
Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/func.sgml,v
retrieving revision 1.187
diff -c -r1.187 func.sgml
*** a/doc/src/sgml/func.sgml	22 Feb 2004 04:14:06 -0000	1.187
--- b/doc/src/sgml/func.sgml	27 Feb 2004 03:47:17 -0000
***************
*** 1003,1009 ****
        
         upper(string)
         text
!        Convert string to upper case
         upper('tom')
         TOM
        
--- 1003,1009 ----
        
         upper(string)
         text
!        Convert string to uppercase
         upper('tom')
         TOM
        
***************
*** 1033,1039 ****
       
        
         ascii(text)
!        integer
         ASCII code of the first character of the argument
         ascii('x')
         120
--- 1033,1039 ----
       
        
         ascii(text)
!        integer
         ASCII code of the first character of the argument
         ascii('x')
         120
***************
*** 1109,1124 ****
        
         initcap(text)
         text
!        Convert first letter of each word (whitespace-separated) to upper case
!        initcap('hi thomas')
         Hi Thomas
        
  
        
!        length(string)
         integer
         
!         Number of characters in string
          
           character string
           length
--- 1109,1128 ----
        
         initcap(text)
         text
!        
!         Convert the first letter of each word to uppercase and the
!         rest to lowercase. Words are sequences of alphanumeric
!         characters separated by non-alphanumeric characters.
!        
!        initcap('hi THOMAS')
         Hi Thomas
        
  
        
!        length(string text)
         integer
         
!         Number of characters in string.
          
           character string
           length
***************
*** 1139,1145 ****
          length integer
          , fill text)
         
!        text
         
          Fill up the string to length
          length by prepending the characters
--- 1143,1149 ----
          length integer
          , fill text)
         
!        text
         
          Fill up the string to length
          length by prepending the characters
***************
*** 1157,1163 ****
         text
         
          Remove the longest string containing only characters from
!         characters from the start of the string.
         
         ltrim('zzzytrim', 'xyz')
         trim
--- 1161,1168 ----
         text
         
          Remove the longest string containing only characters from
!         characters from the start of
!         string.
         
         ltrim('zzzytrim', 'xyz')
         trim
***************
*** 1167,1173 ****
         md5(string text)
         text
         
!         Calculates the MD5 hash of given string, returning the result in hexadecimal.
         
         md5('abc')
         900150983cd24fb0 d6963f7d28e17f72
--- 1172,1179 ----
         md5(string text)
         text
         
!         Calculates the MD5 hash of string,
!         returning the result in hexadecimal.
         
         md5('abc')
         900150983cd24fb0 d6963f7d28e17f72
***************
*** 1210,1218 ****
        
  
        
!        repeat(text, integer)
         text
!        Repeat text a number of times
         repeat('Pg', 4)
         PgPgPgPg
        
--- 1216,1225 ----
        
  
        
!        repeat(string text, number integer)
         text
!        Repeat string the specified
!        number of times
         repeat('Pg', 4)
         PgPgPgPg
        
***************
*** 1253,1259 ****
         text
         
          Remove the longest string containing only characters from
!         characters from the end of the string.
         
         rtrim('trimxxxx', 'x')
         trim
--- 1260,1267 ----
         text
         
          Remove the longest string containing only characters from
!         characters from the end of
!         string.
         
         rtrim('trimxxxx', 'x')
         trim
***************
*** 3956,3967 ****
         
  	AM or A.M. or
  	PM or P.M.
! 	meridian indicator (upper case)
         
         
  	am or a.m. or
  	pm or p.m.
! 	meridian indicator (lower case)
         
         
  	Y,YYY
--- 3964,3975 ----
         
  	AM or A.M. or
  	PM or P.M.
! 	meridian indicator (uppercase)
         
         
  	am or a.m. or
  	pm or p.m.
! 	meridian indicator (lowercase)
         
         
  	Y,YYY
***************
*** 4002,4017 ****
         
  	BC or B.C. or
  	AD or A.D.
! 	era indicator (upper case)
         
         
  	bc or b.c. or
  	ad or a.d.
! 	era indicator (lower case)
         
         
  	MONTH
! 	full upper-case month name (blank-padded to 9 chars)
         
         
  	Month
--- 4010,4025 ----
         
  	BC or B.C. or
  	AD or A.D.
! 	era indicator (uppercase)
         
         
  	bc or b.c. or
  	ad or a.d.
! 	era indicator (lowercase)
         
         
  	MONTH
! 	full uppercase month name (blank-padded to 9 chars)
         
         
  	Month
***************
*** 4019,4029 ****
         
         
  	month
! 	full lower-case month name (blank-padded to 9 chars)
         
         
  	MON
! 	abbreviated upper-case month name (3 chars)
         
         
  	Mon
--- 4027,4037 ----
         
         
  	month
! 	full lowercase month name (blank-padded to 9 chars)
         
         
  	MON
! 	abbreviated uppercase month name (3 chars)
         
         
  	Mon
***************
*** 4031,4037 ****
         
         
  	mon
! 	abbreviated lower-case month name (3 chars)
         
         
  	MM
--- 4039,4045 ----
         
         
  	mon
! 	abbreviated lowercase month name (3 chars)
         
         
  	MM
***************
*** 4039,4045 ****
         
         
  	DAY
! 	full upper-case day name (blank-padded to 9 chars)
         
         
  	Day
--- 4047,4053 ----
         
         
  	DAY
! 	full uppercase day name (blank-padded to 9 chars)
         
         
  	Day
***************
*** 4047,4057 ****
         
         
  	day
! 	full lower-case day name (blank-padded to 9 chars)
         
         
  	DY
! 	abbreviated upper-case day name (3 chars)
         
         
  	Dy
--- 4055,4065 ----
         
         
  	day
! 	full lowercase day name (blank-padded to 9 chars)
         
         
  	DY
! 	abbreviated uppercase day name (3 chars)
         
         
  	Dy
***************
*** 4059,4065 ****
         
         
  	dy
! 	abbreviated lower-case day name (3 chars)
         
         
  	DDD
--- 4067,4073 ----
         
         
  	dy
! 	abbreviated lowercase day name (3 chars)
         
         
  	DDD
***************
*** 4099,4117 ****
         
         
  	RM
! 	month in Roman numerals (I-XII; I=January) (upper case)
         
         
  	rm
! 	month in Roman numerals (i-xii; i=January) (lower case)
         
         
  	TZ
! 	time-zone name (upper case)
         
         
  	tz
! 	time-zone name (lower case)
         
        
       
--- 4107,4125 ----
         
         
  	RM
! 	month in Roman numerals (I-XII; I=January) (uppercase)
         
         
  	rm
! 	month in Roman numerals (i-xii; i=January) (lowercase)
         
         
  	TZ
! 	time-zone name (uppercase)
         
         
  	tz
! 	time-zone name (lowercase)
         
        
       
***************
*** 4144,4155 ****
         
         
  	TH suffix
! 	upper-case ordinal number suffix
  	DDTH
         	
         
  	th suffix
! 	lower-case ordinal number suffix
  	DDth
         
         
--- 4152,4163 ----
         
         
  	TH suffix
! 	uppercase ordinal number suffix
  	DDTH
         	
         
  	th suffix
! 	lowercase ordinal number suffix
  	DDth
         
         
***************
*** 6216,6222 ****
     sequence-function call is specified by a text-string argument.  To
     achieve some compatibility with the handling of ordinary
     SQL names, the sequence functions convert their
!    argument to lower case unless the string is double-quoted.  Thus
  
  nextval('foo')      operates on sequence foo</>
  nextval('FOO')      operates on sequence foo</>
--- 6224,6230 ----
     sequence-function call is specified by a text-string argument.  To
     achieve some compatibility with the handling of ordinary
     SQL names, the sequence functions convert their
!    argument to lowercase unless the string is double-quoted.  Thus
  
  nextval('foo')      operates on sequence foo</>
  nextval('FOO')      operates on sequence foo</>
Index: doc/src/sgml/plpgsql.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/plpgsql.sgml,v
retrieving revision 1.35
diff -c -r1.35 plpgsql.sgml
*** a/doc/src/sgml/plpgsql.sgml	3 Feb 2004 17:34:02 -0000	1.35
--- b/doc/src/sgml/plpgsql.sgml	27 Feb 2004 03:47:48 -0000
***************
*** 392,398 ****
  
      
       All key words and identifiers can be written in mixed upper and
!      lower case.  Identifiers are implicitly converted to lower-case
       unless double-quoted.
      
  
--- 392,398 ----
  
      
       All key words and identifiers can be written in mixed upper and
!      lower case.  Identifiers are implicitly converted to lowercase
       unless double-quoted.
      
  
Index: src/backend/utils/adt/oracle_compat.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/utils/adt/oracle_compat.c,v
retrieving revision 1.49
diff -c -r1.49 oracle_compat.c
*** a/src/backend/utils/adt/oracle_compat.c	29 Nov 2003 19:51:59 -0000	1.49
--- b/src/backend/utils/adt/oracle_compat.c	27 Feb 2004 03:21:00 -0000
***************
*** 106,114 ****
   *
   * Purpose:
   *
!  *	 Returns string, with first letter of each word in uppercase,
!  *	 all other letters in lowercase. A word is delimited by white
!  *	 space.
   *
   ********************************************************************/
  
--- 106,115 ----
   *
   * Purpose:
   *
!  *	 Returns string, with first letter of each word in uppercase, all
!  *	 other letters in lowercase. A word is defined as a sequence of
!  *	 alphanumeric characters, delimited by non-alphanumeric
!  *	 characters.
   *
   ********************************************************************/
  
***************
*** 872,878 ****
   ********************************************************************/
  
  Datum
! chr			(PG_FUNCTION_ARGS)
  {
  	int32		cvalue = PG_GETARG_INT32(0);
  	text	   *result;
--- 873,879 ----
   ********************************************************************/
  
  Datum
! chr(PG_FUNCTION_ARGS)
  {
  	int32		cvalue = PG_GETARG_INT32(0);
  	text	   *result;

Re: Fix doc for initcap

От:
Dennis Bjorklund <db@zigo.dhs.org>
Дата:
On Thu, 26 Feb 2004, Neil Conway wrote:

> The improved text is still wrong: initcap() no longer uses whitespace
> to separate words.

Aha, I didn't know the function had changed at all.

How does it work with respect to the locale? When you say that a word is a 
sequence of alphanum characters, what does that mean if it is a utf-8 
string and we for example have a german locale (or something)?

-- 
/Dennis Björklund

FAQ