You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Martin Sebor <se...@roguewave.com> on 2007/08/24 17:29:36 UTC

Re: svn commit: r569152 - /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp

Andrew, please be sure to observe the 78 characters/line limit
in Change Log entries as documented in bullet (3) of the Patch
Format section on the Bugs page:
   http://incubator.apache.org/stdcxx/bugs.html#patch_format

The reason for this limit in both ChangeLogs and source files
is that they all need to be readable on traditional VT100 text
terminals.

Thanks
Martin

ablack@apache.org wrote:
> Author: ablack
> Date: Thu Aug 23 14:29:06 2007
> New Revision: 569152
> 
> URL: http://svn.apache.org/viewvc?rev=569152&view=rev
> Log:
> 2007-08-23  Andrew Black  <ab...@roguewave.com>
> 	STDCXX-482
> 	* LIMITS.cpp: Deploy http://svn.apache.org/viewvc?view=rev&rev=555106 to 4.2.0 to avoid stalls in nightly testing testing system (caused by usage of the 4.2.0 branch in the nightly testing system.)
> 
> 
> Modified:
>     incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp
> 
> Modified: incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp
> URL: http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp?rev=569152&r1=569151&r2=569152&view=diff
> ==============================================================================
> --- incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp (original)
> +++ incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp Thu Aug 23 14:29:06 2007
> @@ -155,7 +155,7 @@
>  
>  
>  template <class T>
> -T compute_limits (T, const char *pfx, const char *sfx, const char *type)
> +T compute_limits (T *pval, const char *pfx, const char *sfx, const char *type)
>  {
>      T min = T (-one);
>      T max = T (one);
> @@ -167,17 +167,17 @@
>  
>      // compute the maximum representable value
>      for (; T (max * two) > max; max *= two);
> -    for (T n = max / (two + two); n; ) {
> -        if (T (max + n) < max) {
> -            if (n > T (two))
> -                n /= two;
> +    for (*pval = max / (two + two); *pval; ) {
> +        if (T (max + *pval) < max) {
> +            if (*pval > T (two))
> +                *pval /= two;
>              else if (max < T (max + one))
> -                n = one;
> +                *pval = one;
>              else
>                  break;
>          }
>          else
> -            max += n;
> +            max += *pval;
>      }
>  
>      // print the maximum representable value
> @@ -281,18 +281,24 @@
>      }
>      printf ("#define _RWSTD_NO_TWOS_COMPLEMENT\n");
>  
> -    compute_limits ((char)0, "CHAR", "", "char");
> -    compute_limits ((signed char)0, "SCHAR", "", "signed char");
> -    compute_limits ((unsigned char)0, "UCHAR", "U", "unsigned char");
> +#define MKLIMITS(T, pfx, sfx, type)            \
> +    do {                                       \
> +        T buf = 0;                             \
> +        compute_limits (&buf, pfx, sfx, type); \
> +    } while (0)
> +
> +    MKLIMITS (char, "CHAR", "", "char");
> +    MKLIMITS (signed char, "SCHAR", "", "signed char");
> +    MKLIMITS (unsigned char, "UCHAR", "U", "unsigned char");
>  
> -    compute_limits ((short)0, "SHRT", "", "short");
> -    compute_limits ((unsigned short)0, "USHRT", "U", "unsigned short");
> +    MKLIMITS (short, "SHRT", "", "short");
> +    MKLIMITS (unsigned short, "USHRT", "U", "unsigned short");
>  
> -    compute_limits ((int)0, "INT", "", "int");
> -    compute_limits ((unsigned int)0, "UINT", "U", "unsigned int");
> +    MKLIMITS (int, "INT", "", "int");
> +    MKLIMITS (unsigned int, "UINT", "U", "unsigned int");
>  
> -    compute_limits ((long)0, "LONG", "L", "long");
> -    compute_limits ((unsigned long)0, "ULONG", "UL", "unsigned long");
> +    MKLIMITS (long, "LONG", "L", "long");
> +    MKLIMITS (unsigned long, "ULONG", "UL", "unsigned long");
>  
>  #ifndef _RWSTD_NO_LONG_LONG
>  
> @@ -302,8 +308,8 @@
>  
>      const char llong_name[] = "long long";
>  
> -    compute_limits ((LLong)0, "LLONG", "LL", "long long");
> -    compute_limits ((unsigned LLong)0, "ULLONG", "ULL", "unsigned long long");
> +    MKLIMITS (LLong, "LLONG", "LL", "long long");
> +    MKLIMITS (unsigned LLong, "ULLONG", "ULL", "unsigned long long");
>  
>  #else   // if defined (_RWSTD_NO_LONG_LONG)
>  
> @@ -315,9 +321,8 @@
>  
>      const char llong_name[] = "__int64";
>  
> -    compute_limits ((LLong)0, "LLONG", "L", "__int64");
> -    compute_limits ((unsigned LLong)0, "ULLONG", "UL",
> -                    "unsigned __int64");
> +    MKLIMITS (LLong, "LLONG", "L", "__int64");
> +    MKLIMITS (unsigned LLong, "ULLONG", "UL", "unsigned __int64");
>  
>  #    else
>  
> @@ -331,14 +336,14 @@
>  
>  #ifndef _RWSTD_NO_WCHAR_T
>  
> -    printf ("#define _RWSTD_WCHAR_T_SIZE  %2u /* sizeof (wchar_t) */\n",
> +    printf ("#define _RWSTD_WCHAR_SIZE  %2u /* sizeof (wchar_t) */\n",
>              SIZEOF (wchar_t));
>  
>      const char *suffix = "U";
>      if ((wchar_t)~0 < (wchar_t)0)
>          suffix = "";
>      
> -    compute_limits ((wchar_t)0, "WCHAR_T", suffix, "wchar_t");
> +    MKLIMITS (wchar_t, "WCHAR", suffix, "wchar_t");
>  
>  #endif   // _RWSTD_NO_WCHAR_T
>  
> 
> 


Re: svn commit: r569152 - /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp

Posted by Martin Sebor <se...@roguewave.com>.
Mark Brown wrote:
>> -----Original Message-----
>> From: sebor@roguewave.com
>> Sent: Sun, 26 Aug 2007 17:37:02 -0600
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: svn commit: r569152 -
>> /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp
>>
>> Mark Brown wrote:
>>>> -----Original Message-----
>>>> From: sebor@roguewave.com
>>>> Sent: Fri, 24 Aug 2007 09:29:36 -0600
>>>> To: stdcxx-dev@incubator.apache.org
>>>> Subject: Re: svn commit: r569152 -
>>>> /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp
>>>>
>>>> Andrew, please be sure to observe the 78 characters/line limit
>>>> in Change Log entries as documented in bullet (3) of the Patch
>>>> Format section on the Bugs page:
>>>>    http://incubator.apache.org/stdcxx/bugs.html#patch_format
>>>>
>>>> The reason for this limit in both ChangeLogs and source files
>>>> is that they all need to be readable on traditional VT100 text
>>>> terminals.
>>> I have seen coding styles with a 79 character limit (for instance
>>> Python) but I am curious what the rationale for the 78 character limit
>>> is when even the VT100 displays have 80 columns?
>> Opening a file with 80 characters per line in emacs with a buffer
>> width set to 80 columns will wrap the last character of the next
>> line. So if all you have to work with is an 80x24 text terminal
>> and want to run emacs in it you want files to have no more than
>> 79 characters per line. You can recreate this experience in an
>> xterm or similar terminal by setting it to 80 characters and
>> starting emacs with the -nw option.
> 
> If I understand correctly what you're describing, emacs -nw will display lines with up to 79 characters in a 80 column frame without wrapping. What, then, is the rationale for at most 78 characters?

You're right, that was a thinko on my part. Sounds like 79 should
work, but...

I've done some searching online to see what coding standards there
are out there and what rationale they give for imposing which limit.
What I've found is there are standards that impose a limit of 80
characters, others that call for no more than 79 characters, and
others still that require at most 78 characters. However, not all
of them are explicit about what these characters are, specifically
whether the newline separator is or isn't part of the limit. The
killer argument (IMO) in favor of the 78 character limit (not
including the newline, or 79 character limit including it), is
the fact the Unified diff format prepends a character to every
line to indicate whether it is being added ('+') or removed ('-')
or neither. So with at most 78 character lines, diffs still
display correctly on an 80 column display, but at 79 characters
they warp around to the next line.

Here's a reference:
http://amis.sourceforge.net/devel/CppCodingStandard.html#linelen

Martin

Re: svn commit: r569152 - /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp

Posted by Mark Brown <mb...@inbox.com>.
> -----Original Message-----
> From: sebor@roguewave.com
> Sent: Sun, 26 Aug 2007 17:37:02 -0600
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r569152 -
> /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp
> 
> Mark Brown wrote:
>>> -----Original Message-----
>>> From: sebor@roguewave.com
>>> Sent: Fri, 24 Aug 2007 09:29:36 -0600
>>> To: stdcxx-dev@incubator.apache.org
>>> Subject: Re: svn commit: r569152 -
>>> /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp
>>> 
>>> Andrew, please be sure to observe the 78 characters/line limit
>>> in Change Log entries as documented in bullet (3) of the Patch
>>> Format section on the Bugs page:
>>>    http://incubator.apache.org/stdcxx/bugs.html#patch_format
>>> 
>>> The reason for this limit in both ChangeLogs and source files
>>> is that they all need to be readable on traditional VT100 text
>>> terminals.
>> 
>> I have seen coding styles with a 79 character limit (for instance
>> Python) but I am curious what the rationale for the 78 character limit
>> is when even the VT100 displays have 80 columns?
> 
> Opening a file with 80 characters per line in emacs with a buffer
> width set to 80 columns will wrap the last character of the next
> line. So if all you have to work with is an 80x24 text terminal
> and want to run emacs in it you want files to have no more than
> 79 characters per line. You can recreate this experience in an
> xterm or similar terminal by setting it to 80 characters and
> starting emacs with the -nw option.

If I understand correctly what you're describing, emacs -nw will display lines with up to 79 characters in a 80 column frame without wrapping. What, then, is the rationale for at most 78 characters?

-- Mark

Re: svn commit: r569152 - /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp

Posted by Martin Sebor <se...@roguewave.com>.
Mark Brown wrote:
>> -----Original Message-----
>> From: sebor@roguewave.com
>> Sent: Fri, 24 Aug 2007 09:29:36 -0600
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: svn commit: r569152 -
>> /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp
>>
>> Andrew, please be sure to observe the 78 characters/line limit
>> in Change Log entries as documented in bullet (3) of the Patch
>> Format section on the Bugs page:
>>    http://incubator.apache.org/stdcxx/bugs.html#patch_format
>>
>> The reason for this limit in both ChangeLogs and source files
>> is that they all need to be readable on traditional VT100 text
>> terminals.
> 
> I have seen coding styles with a 79 character limit (for instance Python) but I am curious what the rationale for the 78 character limit is when even the VT100 displays have 80 columns?

Opening a file with 80 characters per line in emacs with a buffer
width set to 80 columns will wrap the last character of the next
line. So if all you have to work with is an 80x24 text terminal
and want to run emacs in it you want files to have no more than
79 characters per line. You can recreate this experience in an
xterm or similar terminal by setting it to 80 characters and
starting emacs with the -nw option.

Martin


Re: svn commit: r569152 - /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp

Posted by Mark Brown <mb...@inbox.com>.
> -----Original Message-----
> From: sebor@roguewave.com
> Sent: Fri, 24 Aug 2007 09:29:36 -0600
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: svn commit: r569152 -
> /incubator/stdcxx/branches/4.2.0/etc/config/src/LIMITS.cpp
> 
> Andrew, please be sure to observe the 78 characters/line limit
> in Change Log entries as documented in bullet (3) of the Patch
> Format section on the Bugs page:
>    http://incubator.apache.org/stdcxx/bugs.html#patch_format
> 
> The reason for this limit in both ChangeLogs and source files
> is that they all need to be readable on traditional VT100 text
> terminals.

I have seen coding styles with a 79 character limit (for instance Python) but I am curious what the rationale for the 78 character limit is when even the VT100 displays have 80 columns?

-- Mark