CVS update: /ccvs/
[email protected] 10 Jun 2005 15:31:31 -0000
| Newsgroups | gmane.comp.version-control.cvs.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: mdb Date: 05/06/10 08:31:31 Modified: /ccvs/ ChangeLog, HACKING, cvs-format.el Log: * HACKING: Add a few more guidelines. Adjust examples for switch labels. Fix some spelling mistakes. * cvs-format.el (c-label-offset, case-label): Adjust indentation to agree with changes in the HACKING document. File Changes: Directory: /ccvs/ ================= File [changed]: ChangeLog Url: https://ccvs.cvshome.org/source/browse/ccvs/ChangeLog?r1=1.1225&r2=1.1226 Delta lines: +7 -0 ------------------- --- ChangeLog 3 Jun 2005 17:24:36 -0000 1.1225 +++ ChangeLog 10 Jun 2005 15:31:28 -0000 1.1226 @@ -1,3 +1,10 @@ +2005-06-10 Mark D. Baushke <[email protected]> + + * HACKING: Add a few more guidelines. Adjust examples for switch + labels. Fix some spelling mistakes. + * cvs-format.el (c-label-offset, case-label): Adjust indentation + to agree with changes in the HACKING document. + 2005-06-03 Derek Price <[email protected]> * HACKING: Remove `!= NULL' in example conditional. File [changed]: HACKING Url: https://ccvs.cvshome.org/source/browse/ccvs/HACKING?r1=1.40&r2=1.41 Delta lines: +127 -10 ---------------------- --- HACKING 3 Jun 2005 17:24:36 -0000 1.40 +++ HACKING 10 Jun 2005 15:31:28 -0000 1.41 @@ -50,23 +50,140 @@ case 'A': aflag = 1; break; + case 'E': + go to myerr; } printf ("Literal string line 1\n" "Literal string line 2\n" "Literal string line 3\n"); + return; + + myerr: + printf ("Error argument found\n"); } + - Do not cast NULL unless it is a stdarg argument to a function. + + - Do not cast functions returning (void *), e.g., xmalloc (). + + - Do not cast non-stdarg arguments to a function to '(void *)' + except to drop a 'const' modifier. + + - Snuggle ! close to its expression (i.e., '! foo' => '!foo'). + + - Functions and C statements have a space before the "(" + and the expression does not have a leading or trailing space + (i.e., 'if( foo )' => 'if (foo)'), although it is sometimes + desirable to add a newline after the "(" for #ifdef'd code. + + - For switch statements, indent 'case' by 2 and the body of the case + by an additional 2 spaces. + + - Labels should be indented by 2 spaces rather than the 4 spaces + used by the rest of the current block level. + + + while ((var = next_arg ()) != 0) + { + again: + switch (var) + { + case ONE: + code_for_case_one (); + break; + case TWO: + code_for_case_two (); + break; + case THREE: + push_arg (RESET_ONE); + var = ONE; + go to again; + default: + code_for_default_case (): + break; + } + } + + - NULL-protected free goes on one line if possible, for example: + + if (var) + free (var); + if (var2 != NULL) + free (var2); + + should be written as: + + if (var) free (var); + if (var2) free (var2); + + if the value needs to be set to NULL after the free, then use + + if (var) + { + free (var): + var = NULL; + } + + as the idiom. + + - Use whitespace in arithmetic expressions, for example + + foo (arg+2); + + should be written as + + foo (arg + 2); + + likewise for normal arithmetic expression assignments. + + - Argument lists get a space after a comma. + + - Do not parenthesize return values unless the expression needs to + span multiple lines. + + - Cast negative constants when used in assignments or comparisons + with unsigned types. + + - Try to be consistent with block comments: + + /* This is a good block comment (spanning multiple lines of text). + * It starts with slash-star, leads each line with a star aligned with + * the first, and ends with a similarly aligned star-slash on a line + * by itself. + */ + + /* This is a bad block comment, + because it can make it hard to tell what is code + and what is not code. */ + + - Sentences in comments should have a double space between each + period (.) and the beginning of the next sentence. + + - Conditional expressions that need to be split should put the ? + operator on the new line. + + - Follow GNU standards for breaking logical expressions over + multiple lines where possible. + + - Do not snuggle open-lbrace blocks. + + - Remove '#if 0' code where possible. Add a comment FIXME if it + really is a possible problem. + + - Remove commented-out code where possible (FIXME blocks are + excepted). + The file cvs-format.el contains settings for emacs and the NEWS file contains a set of options for the indent program which I haven't tried but which are correct as far as I know. You will find some code which -does not conform to this indentation style; the plan is to reindent it +does not conform to this indentation style; the plan is to re-indent it as those sections of the code are changed (one function at a time, perhaps). In a submitted patch it is acceptable to refrain from changing the indentation of large blocks of code to minimize the size of the patch; -the person checking in such a patch should reindent it. +the person checking in such a patch should re-indent it. * Portability @@ -87,7 +204,7 @@ freestanding C89 implementation: <float.h>, <limits.h>, <stdarg.h>, <stddef.h>. We are not assuming the other standard headers listed by C89 (hosted headers) because these four headers are the only headers guaranteed to be shipped with -a C89 compiler (frestanding compiler). We are not currently assuming that the +a C89 compiler (freestanding compiler). We are not currently assuming that the system the compiler is running on provides the rest of the C89 headers. The following C89 hosted headers can be assumed due to their presence in UNIX @@ -113,8 +230,8 @@ limitations. <sys/types.h> can be assumed despite a lack of a presence in even C99, since -it has been around nearly forever and noone has ever complained about our code -assuming its existance. +it has been around nearly forever and no-one has ever complained about our code +assuming its existence. CVS has also been assuming <pwd.h> for some time. I am unsure of the rationale. @@ -164,7 +281,7 @@ lot of time getting rid of them, and we don't want to put them back. If you find any that we missed, please report it as with other bugs. In most cases such code will create security holes (for example, for -anonymous readonly access via the CVS protocol, or if a WWW cgi script +anonymous read-only access via the CVS protocol, or if a WWW cgi script passes client-supplied arguments to CVS). Although this is a long-term goal, it also would be nice to move CVS @@ -228,7 +345,7 @@ Distribute some experimental patches and see what people think. The intention is arrive at some kind of rough community consensus before changing the "official" CVS. Features like zlib, encryption, and -the RCS library have benefitted from this process in the past. +the RCS library have benefited from this process in the past. If longstanding CVS behavior, that people may be relying on, is clearly deficient, it can be changed, but only slowly and carefully. File [changed]: cvs-format.el Url: https://ccvs.cvshome.org/source/browse/ccvs/cvs-format.el?r1=1.5&r2=1.6 Delta lines: +2 -2 ------------------- --- cvs-format.el 17 Mar 2005 01:38:16 -0000 1.5 +++ cvs-format.el 10 Jun 2005 15:31:28 -0000 1.6 @@ -103,7 +103,7 @@ ;; style. But if one manually aligns the first case, then the rest ;; should work OK. (if (boundp 'c-label-offset) - (setq c-label-offset -4)) + (setq c-label-offset -2)) ;; ;; @@ -126,7 +126,7 @@ (knr-argdecl-intro . 4) (substatement-open . 0) (label . 2) - (case-label . +) + (case-label . 2) (statement-case-open . +) (statement-cont . +) (arglist-intro . c-lineup-arglist-intro-after-paren)