commit 645e7ec
default
·
2022-12-14 03:55:47 +0000 UTC
parent f5086fe
Some code reordering to placate scan-build's wrath.
3 files changed,
+25,
-14
+14,
-6
1@@ -264,7 +264,9 @@ void process_tags(const char *content, d_char **n_content, d_char **tag)
2 char *p, *v;
3 int n = 0;
4
5- p = split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)");
6+ split = xs_regex_split(content, "(@[A-Za-z0-9_]+@[A-Za-z0-9\\.-]+|#[^ ,\\.:;]+)");
7+
8+ p = split;
9 while (xs_list_iter(&p, &v)) {
10 if ((n & 0x1)) {
11 if (*v == '@') {
12@@ -320,18 +322,24 @@ d_char *msg_base(snac *snac, char *type, char *id, char *actor, char *date, char
13 xs *published = NULL;
14
15 /* generated values */
16- if (date && strcmp(date, "@now") == 0)
17- date = published = xs_str_utctime(0, "%Y-%m-%dT%H:%M:%SZ");
18+ if (date && strcmp(date, "@now") == 0) {
19+ published = xs_str_utctime(0, "%Y-%m-%dT%H:%M:%SZ");
20+ date = published;
21+ }
22
23 if (id != NULL) {
24 if (strcmp(id, "@dummy") == 0) {
25 xs *ntid = tid(0);
26- id = did = xs_fmt("%s/d/%s/%s", snac->actor, ntid, type);
27+ did = xs_fmt("%s/d/%s/%s", snac->actor, ntid, type);
28+
29+ id = did;
30 }
31 else
32 if (strcmp(id, "@object") == 0) {
33- if (object != NULL)
34- id = did = xs_fmt("%s/%s", xs_dict_get(object, "id"), type);
35+ if (object != NULL) {
36+ did = xs_fmt("%s/%s", xs_dict_get(object, "id"), type);
37+ id = did;
38+ }
39 else
40 id = NULL;
41 }
M
format.c
+2,
-1
1@@ -98,8 +98,9 @@ d_char *not_really_markdown(const char *content)
2 char *p, *v;
3
4 /* work by lines */
5- p = list = xs_split(content, "\n");
6+ list = xs_split(content, "\n");
7
8+ p = list;
9 while (xs_list_iter(&p, &v)) {
10 xs *ss = NULL;
11
M
snac.c
+9,
-7
1@@ -74,17 +74,17 @@ int validate_uid(const char *uid)
2 void srv_debug(int level, d_char *str)
3 /* logs a debug message */
4 {
5- xs *msg = str;
6-
7- if (xs_str_in(msg, srv_basedir) != -1) {
8+ if (xs_str_in(str, srv_basedir) != -1) {
9 /* replace basedir with ~ */
10- msg = xs_replace_i(msg, srv_basedir, "~");
11+ str = xs_replace_i(str, srv_basedir, "~");
12 }
13
14 if (dbglevel >= level) {
15 xs *tm = xs_str_localtime(0, "%H:%M:%S");
16- fprintf(stderr, "%s %s\n", tm, msg);
17+ fprintf(stderr, "%s %s\n", tm, str);
18 }
19+
20+ xs_free(str);
21 }
22
23
24@@ -110,8 +110,10 @@ d_char *hash_password(const char *uid, const char *passwd, const char *nonce)
25 xs *combi;
26 xs *hash;
27
28- if (nonce == NULL)
29- nonce = d_nonce = xs_fmt("%08x", random());
30+ if (nonce == NULL) {
31+ d_nonce = xs_fmt("%08x", random());
32+ nonce = d_nonce;
33+ }
34
35 combi = xs_fmt("%s:%s:%s", nonce, uid, passwd);
36 hash = xs_sha1_hex(combi, strlen(combi));