Fossil SCM

Remove unnecessary field from the auxiliary union <code>'bitfield64_t'</code> and amend the corresponding comments. Also add comment about FOOTNOTES_WITHOUT_URI macro.

george 2022-04-19 15:25 markdown-footnotes
Commit cf1e96918edcd232723aaa9d1d1b34565828edcb9a3a70a8101edb94a48a8069
1 file changed +14 -5
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -31,16 +31,16 @@
3131
3232
#endif /* INTERFACE */
3333
3434
/*
3535
** Markdown-internal helper for generating unique link reference IDs.
36
+** Fields provide typed interpretation of the underline memory buffer.
3637
*/
3738
typedef union bitfield64_t bitfield64_t;
3839
union bitfield64_t{
39
- uint64_t u;
40
- char c[8];
41
- unsigned char b[8];
40
+ char c[8]; /* interpret as the array of signed characters */
41
+ unsigned char b[8]; /* interpret as the array of unsigned characters */
4242
};
4343
4444
/*
4545
** An instance of the following structure is passed through the
4646
** "opaque" pointer.
@@ -58,22 +58,31 @@
5858
5959
/* INTER_BLOCK -- skip a line between block level elements */
6060
#define INTER_BLOCK(ob) \
6161
do { if( blob_size(ob)>0 ) blob_append_char(ob, '\n'); } while (0)
6262
63
+/*
64
+** FOOTNOTES_WITHOUT_URI macro was introduced by [2c1f8f3592ef00e0]
65
+** to enable flexibility in rendering of footnote-specific hyperlinks.
66
+** It may be defined for a particular build in order to omit
67
+** full REQUEST_URIs within footnote-specific (and page-local) hyperlinks.
68
+** This *is* used for the builds that incorporate 'base-href-fix' branch
69
+** (which in turn fixes footnotes on the preview tab of /wikiedit page).
70
+*/
6371
#ifndef FOOTNOTES_WITHOUT_URI
6472
#define BLOB_APPEND_URI(dest,ctx) blob_appendb(dest,&((ctx)->reqURI))
6573
#else
6674
#define BLOB_APPEND_URI(dest,ctx)
6775
#endif
6876
69
-/* Converts an integer to a null-terminated base26 representation
77
+/* Converts an integer to a textual base26 representation
78
+** with proper null-termination.
7079
* Return empty string if that integer is negative. */
7180
static bitfield64_t to_base26(int i, int uppercase){
7281
bitfield64_t x;
7382
int j;
74
- x.u = 0;
83
+ memset( &x, 0, sizeof(x) );
7584
if( i >= 0 ){
7685
for(j=7; j >= 0; j--){
7786
x.b[j] = (unsigned char)(uppercase?'A':'a') + i%26;
7887
if( (i /= 26) == 0 ) break;
7988
}
8089
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -31,16 +31,16 @@
31
32 #endif /* INTERFACE */
33
34 /*
35 ** Markdown-internal helper for generating unique link reference IDs.
 
36 */
37 typedef union bitfield64_t bitfield64_t;
38 union bitfield64_t{
39 uint64_t u;
40 char c[8];
41 unsigned char b[8];
42 };
43
44 /*
45 ** An instance of the following structure is passed through the
46 ** "opaque" pointer.
@@ -58,22 +58,31 @@
58
59 /* INTER_BLOCK -- skip a line between block level elements */
60 #define INTER_BLOCK(ob) \
61 do { if( blob_size(ob)>0 ) blob_append_char(ob, '\n'); } while (0)
62
 
 
 
 
 
 
 
 
63 #ifndef FOOTNOTES_WITHOUT_URI
64 #define BLOB_APPEND_URI(dest,ctx) blob_appendb(dest,&((ctx)->reqURI))
65 #else
66 #define BLOB_APPEND_URI(dest,ctx)
67 #endif
68
69 /* Converts an integer to a null-terminated base26 representation
 
70 * Return empty string if that integer is negative. */
71 static bitfield64_t to_base26(int i, int uppercase){
72 bitfield64_t x;
73 int j;
74 x.u = 0;
75 if( i >= 0 ){
76 for(j=7; j >= 0; j--){
77 x.b[j] = (unsigned char)(uppercase?'A':'a') + i%26;
78 if( (i /= 26) == 0 ) break;
79 }
80
--- src/markdown_html.c
+++ src/markdown_html.c
@@ -31,16 +31,16 @@
31
32 #endif /* INTERFACE */
33
34 /*
35 ** Markdown-internal helper for generating unique link reference IDs.
36 ** Fields provide typed interpretation of the underline memory buffer.
37 */
38 typedef union bitfield64_t bitfield64_t;
39 union bitfield64_t{
40 char c[8]; /* interpret as the array of signed characters */
41 unsigned char b[8]; /* interpret as the array of unsigned characters */
 
42 };
43
44 /*
45 ** An instance of the following structure is passed through the
46 ** "opaque" pointer.
@@ -58,22 +58,31 @@
58
59 /* INTER_BLOCK -- skip a line between block level elements */
60 #define INTER_BLOCK(ob) \
61 do { if( blob_size(ob)>0 ) blob_append_char(ob, '\n'); } while (0)
62
63 /*
64 ** FOOTNOTES_WITHOUT_URI macro was introduced by [2c1f8f3592ef00e0]
65 ** to enable flexibility in rendering of footnote-specific hyperlinks.
66 ** It may be defined for a particular build in order to omit
67 ** full REQUEST_URIs within footnote-specific (and page-local) hyperlinks.
68 ** This *is* used for the builds that incorporate 'base-href-fix' branch
69 ** (which in turn fixes footnotes on the preview tab of /wikiedit page).
70 */
71 #ifndef FOOTNOTES_WITHOUT_URI
72 #define BLOB_APPEND_URI(dest,ctx) blob_appendb(dest,&((ctx)->reqURI))
73 #else
74 #define BLOB_APPEND_URI(dest,ctx)
75 #endif
76
77 /* Converts an integer to a textual base26 representation
78 ** with proper null-termination.
79 * Return empty string if that integer is negative. */
80 static bitfield64_t to_base26(int i, int uppercase){
81 bitfield64_t x;
82 int j;
83 memset( &x, 0, sizeof(x) );
84 if( i >= 0 ){
85 for(j=7; j >= 0; j--){
86 x.b[j] = (unsigned char)(uppercase?'A':'a') + i%26;
87 if( (i /= 26) == 0 ) break;
88 }
89

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button