Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–6 unchanged (6 lines)
7 * must stay backwards-compatible!
8 */
9
10#include "postgres.h"
11#include "ltree.h"
12
13#ifdef LOWER_NODE
14#include <ctype.h>
15#define TOLOWER(x) tolower((unsigned char) (x))
16#else
17#define TOLOWER(x) (x)
18#endif
19
20#include "crc32.h"
21#include "utils/pg_crc.h"
22
23unsigned int
24ltree_crc32_sz(const char *buf, int size)
25{
26 pg_crc32 crc;
27 const char *p = buf;
28
29 INIT_TRADITIONAL_CRC32(crc);
30 while (size > 0)
31 {
32 char c = (char) TOLOWER(*p);
33
34 COMP_TRADITIONAL_CRC32(crc, &c, 1);
35 size--;
36 p++;
37 }
38 FIN_TRADITIONAL_CRC32(crc);
39 return (unsigned int) crc;
40}
41

After

…lines 1–6 unchanged (6 lines)
7 * must stay backwards-compatible!
8 */
9
10#include "postgres.h"
11#include "ltree.h"
12
13#include "crc32.h"
14#include "utils/pg_crc.h"
15#ifdef LOWER_NODE
16#include "utils/pg_locale.h"
17#endif
18
19#ifdef LOWER_NODE
20
21unsigned int
22ltree_crc32_sz(const char *buf, int size)
23{
24 pg_crc32 crc;
25 const char *p = buf;
26 static pg_locale_t locale = NULL;
27
28 if (!locale)
29 locale = pg_database_locale();
30
31 INIT_TRADITIONAL_CRC32(crc);
32 while (size > 0)
33 {
34 char foldstr[UNICODE_CASEMAP_BUFSZ];
35 int srclen = pg_mblen(p);
36 size_t foldlen;
37
38 /* fold one codepoint at a time */
39 foldlen = pg_strfold(foldstr, UNICODE_CASEMAP_BUFSZ, p, srclen,
40 locale);
41
42 COMP_TRADITIONAL_CRC32(crc, foldstr, foldlen);
43
44 size -= srclen;
45 p += srclen;
46 }
47 FIN_TRADITIONAL_CRC32(crc);
48 return (unsigned int) crc;
49}
50
51#else
52
53unsigned int
54ltree_crc32_sz(const char *buf, int size)
55{
56 pg_crc32 crc;
57 const char *p = buf;
58
59 INIT_TRADITIONAL_CRC32(crc);
60 while (size > 0)
61 {
62 COMP_TRADITIONAL_CRC32(crc, p, 1);
63 size--;
64 p++;
65 }
66 FIN_TRADITIONAL_CRC32(crc);
67 return (unsigned int) crc;
68}
69
70#endif /* !LOWER_NODE */
71

Before

translation_unit
comment "/* contrib/ltree/crc32.c */"
comment "/*\n * Implements CRC-32, as used in ltree.\n *\n * Note that t"...
preproc_include
#include "#include"
string_literal
" "\""
string_content "postgres.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "ltree.h"
" "\""
preproc_ifdef
#ifdef "#ifdef"
identifier "LOWER_NODE"
preproc_include
#include "#include"
system_lib_string "<ctype.h>"
preproc_function_def
#define "#define"
identifier "TOLOWER"
preproc_params
( "("
identifier "x"
) ")"
preproc_arg "tolower((unsigned char) (x))"
preproc_else
#else "#else"
preproc_function_def
#define "#define"
identifier "TOLOWER"
preproc_params
( "("
identifier "x"
) ")"
preproc_arg "(x)"
#endif "#endif"
preproc_include
#include "#include"
string_literal
" "\""
string_content "crc32.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "utils/pg_crc.h"
" "\""
function_definition
sized_type_specifier
unsigned "unsigned"
primitive_type "int"
function_declarator
identifier "ltree_crc32_sz"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
primitive_type "char"
pointer_declarator
* "*"
identifier "buf"
, ","
parameter_declaration
primitive_type "int"
identifier "size"
) ")"
compound_statement
{ "{"
declaration
type_identifier "pg_crc32"
identifier "crc"
; ";"
declaration
type_qualifier
const "const"
primitive_type "char"
init_declarator
pointer_declarator
* "*"
identifier "p"
= "="
identifier "buf"
; ";"
expression_statement
call_expression
identifier "INIT_TRADITIONAL_CRC32"
argument_list
( "("
identifier "crc"
) ")"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
identifier "size"
> ">"
number_literal "0"
) ")"
compound_statement
{ "{"
declaration
primitive_type "char"
init_declarator
identifier "c"
= "="
cast_expression
( "("
type_descriptor
primitive_type "char"
) ")"
call_expression
identifier "TOLOWER"
argument_list
( "("
pointer_expression
* "*"
identifier "p"
) ")"
; ";"
expression_statement
call_expression
identifier "COMP_TRADITIONAL_CRC32"
argument_list
( "("
identifier "crc"
, ","
pointer_expression
& "&"
identifier "c"
, ","
number_literal "1"
) ")"
; ";"
expression_statement
update_expression
identifier "size"
-- "--"
; ";"
expression_statement
update_expression
identifier "p"
++ "++"
; ";"
} "}"
expression_statement
call_expression
identifier "FIN_TRADITIONAL_CRC32"
argument_list
( "("
identifier "crc"
) ")"
; ";"
return_statement
return "return"
cast_expression
( "("
type_descriptor
sized_type_specifier
unsigned "unsigned"
primitive_type "int"
) ")"
identifier "crc"
; ";"
} "}"

After

translation_unit
comment "/* contrib/ltree/crc32.c */"
comment "/*\n * Implements CRC-32, as used in ltree.\n *\n * Note that t"...
preproc_include
#include "#include"
string_literal
" "\""
string_content "postgres.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "ltree.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "crc32.h"
" "\""
preproc_include
#include "#include"
string_literal
" "\""
string_content "utils/pg_crc.h"
" "\""
preproc_ifdef
#ifdef "#ifdef"
identifier "LOWER_NODE"
preproc_include
#include "#include"
string_literal
" "\""
string_content "utils/pg_locale.h"
" "\""
#endif "#endif"
preproc_ifdef
#ifdef "#ifdef"
identifier "LOWER_NODE"
function_definition
sized_type_specifier
unsigned "unsigned"
primitive_type "int"
function_declarator
identifier "ltree_crc32_sz"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
primitive_type "char"
pointer_declarator
* "*"
identifier "buf"
, ","
parameter_declaration
primitive_type "int"
identifier "size"
) ")"
compound_statement
{ "{"
declaration
type_identifier "pg_crc32"
identifier "crc"
; ";"
declaration
type_qualifier
const "const"
primitive_type "char"
init_declarator
pointer_declarator
* "*"
identifier "p"
= "="
identifier "buf"
; ";"
declaration
storage_class_specifier
static "static"
type_identifier "pg_locale_t"
init_declarator
identifier "locale"
= "="
null
NULL "NULL"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
unary_expression
! "!"
identifier "locale"
) ")"
expression_statement
assignment_expression
identifier "locale"
= "="
call_expression
identifier "pg_database_locale"
argument_list
( "("
) ")"
; ";"
expression_statement
call_expression
identifier "INIT_TRADITIONAL_CRC32"
argument_list
( "("
identifier "crc"
) ")"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
identifier "size"
> ">"
number_literal "0"
) ")"
compound_statement
{ "{"
declaration
primitive_type "char"
array_declarator
identifier "foldstr"
[ "["
identifier "UNICODE_CASEMAP_BUFSZ"
] "]"
; ";"
declaration
primitive_type "int"
init_declarator
identifier "srclen"
= "="
call_expression
identifier "pg_mblen"
argument_list
( "("
identifier "p"
) ")"
; ";"
declaration
primitive_type "size_t"
identifier "foldlen"
; ";"
comment "/* fold one codepoint at a time */"
expression_statement
assignment_expression
identifier "foldlen"
= "="
call_expression
identifier "pg_strfold"
argument_list
( "("
identifier "foldstr"
, ","
identifier "UNICODE_CASEMAP_BUFSZ"
, ","
identifier "p"
, ","
identifier "srclen"
, ","
identifier "locale"
) ")"
; ";"
expression_statement
call_expression
identifier "COMP_TRADITIONAL_CRC32"
argument_list
( "("
identifier "crc"
, ","
identifier "foldstr"
, ","
identifier "foldlen"
) ")"
; ";"
expression_statement
assignment_expression
identifier "size"
-= "-="
identifier "srclen"
; ";"
expression_statement
assignment_expression
identifier "p"
+= "+="
identifier "srclen"
; ";"
} "}"
expression_statement
call_expression
identifier "FIN_TRADITIONAL_CRC32"
argument_list
( "("
identifier "crc"
) ")"
; ";"
return_statement
return "return"
cast_expression
( "("
type_descriptor
sized_type_specifier
unsigned "unsigned"
primitive_type "int"
) ")"
identifier "crc"
; ";"
} "}"
preproc_else
#else "#else"
function_definition
sized_type_specifier
unsigned "unsigned"
primitive_type "int"
function_declarator
identifier "ltree_crc32_sz"
parameter_list
( "("
parameter_declaration
type_qualifier
const "const"
primitive_type "char"
pointer_declarator
* "*"
identifier "buf"
, ","
parameter_declaration
primitive_type "int"
identifier "size"
) ")"
compound_statement
{ "{"
declaration
type_identifier "pg_crc32"
identifier "crc"
; ";"
declaration
type_qualifier
const "const"
primitive_type "char"
init_declarator
pointer_declarator
* "*"
identifier "p"
= "="
identifier "buf"
; ";"
expression_statement
call_expression
identifier "INIT_TRADITIONAL_CRC32"
argument_list
( "("
identifier "crc"
) ")"
; ";"
while_statement
while "while"
parenthesized_expression
( "("
binary_expression
identifier "size"
> ">"
number_literal "0"
) ")"
compound_statement
{ "{"
expression_statement
call_expression
identifier "COMP_TRADITIONAL_CRC32"
argument_list
( "("
identifier "crc"
, ","
identifier "p"
, ","
number_literal "1"
) ")"
; ";"
expression_statement
update_expression
identifier "size"
-- "--"
; ";"
expression_statement
update_expression
identifier "p"
++ "++"
; ";"
} "}"
expression_statement
call_expression
identifier "FIN_TRADITIONAL_CRC32"
argument_list
( "("
identifier "crc"
) ")"
; ";"
return_statement
return "return"
cast_expression
( "("
type_descriptor
sized_type_specifier
unsigned "unsigned"
primitive_type "int"
) ")"
identifier "crc"
; ";"
} "}"
#endif "#endif"
comment "/* !LOWER_NODE */"