1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-11 16:58:40 +03:00

README: Add languages to code blocks for highlighting

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Sep  5 14:27:30 UTC 2024 on atb-devel-224
This commit is contained in:
Andreas Schneider 2024-06-28 13:01:24 +02:00 committed by Volker Lendecke
parent 22edd69503
commit 7bd8234152

View File

@ -48,7 +48,7 @@ are the highlights.
Add the follow to your $HOME/.emacs file: Add the follow to your $HOME/.emacs file:
``` ```lisp
(add-hook 'c-mode-hook (add-hook 'c-mode-hook
(lambda () (lambda ()
(c-set-style "linux") (c-set-style "linux")
@ -63,7 +63,7 @@ Add the follow to your $HOME/.emacs file:
For the basic vi editor included with all variants of \*nix, add the For the basic vi editor included with all variants of \*nix, add the
following to $HOME/.exrc: following to $HOME/.exrc:
``` ```vim
set tabstop=8 set tabstop=8
set shiftwidth=8 set shiftwidth=8
``` ```
@ -71,7 +71,7 @@ following to $HOME/.exrc:
For Vim, the following settings in $HOME/.vimrc will also deal with For Vim, the following settings in $HOME/.vimrc will also deal with
displaying trailing whitespace: displaying trailing whitespace:
``` ```vim
if has("syntax") && (&t_Co > 2 || has("gui_running")) if has("syntax") && (&t_Co > 2 || has("gui_running"))
syntax on syntax on
function! ActivateInvisibleCharIndicator() function! ActivateInvisibleCharIndicator()
@ -113,7 +113,7 @@ of multiple following code blocks.
This is good: This is good:
``` ```c
... ...
int i; int i;
@ -153,7 +153,7 @@ This is good:
This is bad: This is bad:
``` ```c
... ...
int i; int i;
/* /*
@ -191,7 +191,7 @@ align the parameter list with the first parameter on the previous line.
Use tabs to get as close as possible and then fill in the final 7 Use tabs to get as close as possible and then fill in the final 7
characters or less with whitespace. For example, characters or less with whitespace. For example,
``` ```c
var1 = foo(arg1, arg2, var1 = foo(arg1, arg2,
arg3); arg3);
``` ```
@ -214,13 +214,13 @@ Always follow an `if` keyword with a space but don't include additional
spaces following or preceding the parentheses in the conditional. spaces following or preceding the parentheses in the conditional.
This is good: This is good:
``` ```c
if (x == 1) if (x == 1)
``` ```
This is bad: This is bad:
``` ```c
if ( x == 1 ) if ( x == 1 )
``` ```
@ -246,7 +246,7 @@ loop.
Good examples: Good examples:
``` ```c
if (x == 1) { if (x == 1) {
printf("good\n"); printf("good\n");
} }
@ -269,7 +269,7 @@ Good examples:
Bad examples: Bad examples:
``` ```c
while (1) while (1)
{ {
print("I'm in a loop!\n"); } print("I'm in a loop!\n"); }
@ -296,7 +296,7 @@ idea.
Good Examples: Good Examples:
``` ```c
int function foo(int y) int function foo(int y)
{ {
int *z = NULL; int *z = NULL;
@ -338,7 +338,7 @@ lib/replace/, new code should adhere to the following conventions:
Most of the time a good name for a boolean variable is 'ok'. Here is an Most of the time a good name for a boolean variable is 'ok'. Here is an
example we often use: example we often use:
``` ```c
bool ok; bool ok;
ok = foo(); ok = foo();
@ -367,7 +367,7 @@ instructions sequence may change over time.
Good Example: Good Example:
``` ```c
char *pointer1 = NULL; char *pointer1 = NULL;
char *pointer2 = NULL; char *pointer2 = NULL;
@ -380,7 +380,7 @@ Good Example:
Bad Example: Bad Example:
``` ```c
char *pointer1; char *pointer1;
char *pointer2; char *pointer2;
@ -441,7 +441,7 @@ it's also easier to use the "step" command within gdb.
Good Example: Good Example:
``` ```c
char *name = NULL; char *name = NULL;
int ret; int ret;
@ -457,7 +457,7 @@ Good Example:
Bad Example: Bad Example:
``` ```c
ret = some_function_my_name(get_some_name()); ret = some_function_my_name(get_some_name());
... ...
``` ```
@ -468,7 +468,7 @@ debugger.
Good example: Good example:
``` ```c
x = malloc(sizeof(short)*10); x = malloc(sizeof(short)*10);
if (x == NULL) { if (x == NULL) {
fprintf(stderr, "Unable to alloc memory!\n"); fprintf(stderr, "Unable to alloc memory!\n");
@ -477,7 +477,7 @@ Good example:
Bad example: Bad example:
``` ```c
if ((x = malloc(sizeof(short)*10)) == NULL ) { if ((x = malloc(sizeof(short)*10)) == NULL ) {
fprintf(stderr, "Unable to alloc memory!\n"); fprintf(stderr, "Unable to alloc memory!\n");
} }
@ -486,7 +486,7 @@ Bad example:
There are exceptions to this rule. One example is walking a data structure in There are exceptions to this rule. One example is walking a data structure in
an iterator style: an iterator style:
``` ```c
while ((opt = poptGetNextOpt(pc)) != -1) { while ((opt = poptGetNextOpt(pc)) != -1) {
... do something with opt ... ... do something with opt ...
} }
@ -499,7 +499,7 @@ rarely exists for this particular use case, and we gain some
efficiency because the DBG_ macros don't evaluate their arguments if efficiency because the DBG_ macros don't evaluate their arguments if
the debuglevel is not high enough. the debuglevel is not high enough.
``` ```c
if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_IS_OK(status)) {
struct dom_sid_buf sid_buf; struct dom_sid_buf sid_buf;
struct GUID_txt_buf guid_buf; struct GUID_txt_buf guid_buf;
@ -528,7 +528,7 @@ like `CHECK_STATUS`, `CHECK_VAL` and others.
Don't do this: Don't do this:
``` ```c
frame = talloc_stackframe(); frame = talloc_stackframe();
if (ret == LDB_SUCCESS) { if (ret == LDB_SUCCESS) {
@ -551,7 +551,7 @@ Don't do this:
It should be: It should be:
``` ```c
frame = talloc_stackframe(); frame = talloc_stackframe();
if (ret != LDB_SUCCESS) { if (ret != LDB_SUCCESS) {
@ -580,7 +580,7 @@ It should be:
Use these following macros instead of DEBUG: Use these following macros instead of DEBUG:
``` ```c
DBG_ERR log level 0 error conditions DBG_ERR log level 0 error conditions
DBG_WARNING log level 1 warning conditions DBG_WARNING log level 1 warning conditions
DBG_NOTICE log level 3 normal, but significant, condition DBG_NOTICE log level 3 normal, but significant, condition
@ -590,7 +590,7 @@ DBG_DEBUG log level 10 debug-level message
Example usage: Example usage:
``` ```c
DBG_ERR("Memory allocation failed\n"); DBG_ERR("Memory allocation failed\n");
DBG_DEBUG("Received %d bytes\n", count); DBG_DEBUG("Received %d bytes\n", count);
``` ```
@ -613,7 +613,7 @@ The PRIuxx specifiers are standard.
Example usage: Example usage:
``` ```c
D_DEBUG("Resolving %"PRIu32" SID(s).\n", state->num_sids); D_DEBUG("Resolving %"PRIu32" SID(s).\n", state->num_sids);
``` ```