[FIX] Make codebase *slightly* NetBSD-friendly

I need to make it so that NetBSD targets get their own
correctness/build checks in CI. I also had to do some hacks with
Cytoplasm, will make a PR for those soon.
This commit is contained in:
LDA 2024-10-22 10:21:54 +02:00
commit b0cf0961a3
13 changed files with 35 additions and 25 deletions

14
CONTRIBUTORS Normal file
View file

@ -0,0 +1,14 @@
# Lines starting with a '#' are ignored.
# This is a list of people who have contributed to Parsee.
# You *may* add some information about yourself after having made a change
# to the repository(or wiki!), with those fields:
# (N) - A nickname
# (L) - An approximate place of residence
# (X) - An XMPP URI
# (M) - A Matrix MXID
# (D) - A short description about yourself
(N): LDA
(L): France
(X): xmpp:lda@monocles.eu
(M): @fourier:ari.lt
(M): @fourier:ari.lt

View file

@ -531,7 +531,7 @@ main_build(int argc, char *argv[])
fprintf(makefile, "-DNAME=\"\\\"$(NAME)\\\"\" "); fprintf(makefile, "-DNAME=\"\\\"$(NAME)\\\"\" ");
fprintf(makefile, "-DCODE=\"\\\"$(CODE)\\\"\" "); fprintf(makefile, "-DCODE=\"\\\"$(CODE)\\\"\" ");
fprintf(makefile, "-DREPOSITORY=\"\\\"%s\\\"\" ", repo); fprintf(makefile, "-DREPOSITORY=\"\\\"%s\\\"\" ", repo);
fprintf(makefile, "$(CFLAGS) $< -o $@\n"); fprintf(makefile, "$(CFLAGS) %s -o %s\n", src, obj);
} }
free(ofl); free(ofl);
free(obj); free(obj);
@ -560,8 +560,8 @@ main_build(int argc, char *argv[])
sym = string_rep_ext(sym, ".o", ""); sym = string_rep_ext(sym, ".o", "");
str_array_free(s); str_array_free(s);
fprintf(makefile, "\ttools/out/b64 $< 'media_%s' '%s.c'\n", sym, obj); fprintf(makefile, "\ttools/out/b64 %s 'media_%s' '%s.c'\n", src, sym, obj);
fprintf(makefile, "\t$(CC) -c %s.c -o $@\n", obj); fprintf(makefile, "\t$(CC) -c %s.c -o %s\n", obj, obj);
free(sym); free(sym);
} }
free(obj); free(obj);
@ -583,12 +583,12 @@ main_build(int argc, char *argv[])
fprintf(makefile, "%s: %s\n", obj, src); fprintf(makefile, "%s: %s\n", obj, src);
{ {
fprintf(makefile, "\t@mkdir -p tools/out\n"); fprintf(makefile, "\t@mkdir -p tools/out\n");
fprintf(makefile, "\t$(CC) -o $@"); fprintf(makefile, "\t$(CC) -o %s", obj);
if (with_static) if (with_static)
{ {
fprintf(makefile, " -static"); fprintf(makefile, " -static");
} }
fprintf(makefile, " $<"); fprintf(makefile, " %s", src);
fprintf(makefile, " -I $(CYTO_INC)"); fprintf(makefile, " -I $(CYTO_INC)");
fprintf(makefile, " -L $(CYTO_LIB)"); fprintf(makefile, " -L $(CYTO_LIB)");
if (with_static) if (with_static)
@ -632,7 +632,7 @@ main_build(int argc, char *argv[])
"\ttools/out/aya " "\ttools/out/aya "
"-C etc/ayadoc/style.css " "-C etc/ayadoc/style.css "
"-p $(NAME) " "-p $(NAME) "
"-i $< -o $@\n" "-i %s -o %s\n", src, obj
); );
} }

View file

@ -73,7 +73,7 @@ ASBan(const ParseeConfig *conf, char *id, char *banned)
Free(path); Free(path);
json = HashMapCreate(); json = HashMapCreate();
HashMapSet(json, "user_id", JsonValueString(banned)); HashMapSet(json, "user_id", JsonValueString(banned));
HashMapSet(json, "reason", JsonValueString("Parsee felt jealous.")); HashMapSet(json, "reason", JsonValueString(NAME " felt jealous."));
ASAuthenticateRequest(conf, ctx); ASAuthenticateRequest(conf, ctx);
ParseeSetRequestJSON(ctx, json); ParseeSetRequestJSON(ctx, json);
@ -108,7 +108,7 @@ ASKick(const ParseeConfig *conf, char *id, char *banned)
Free(path); Free(path);
json = HashMapCreate(); json = HashMapCreate();
HashMapSet(json, "user_id", JsonValueString(banned)); HashMapSet(json, "user_id", JsonValueString(banned));
HashMapSet(json, "reason", JsonValueString("Parsee felt jealous.")); HashMapSet(json, "reason", JsonValueString(NAME " felt jealous."));
ASAuthenticateRequest(conf, ctx); ASAuthenticateRequest(conf, ctx);
ParseeSetRequestJSON(ctx, json); ParseeSetRequestJSON(ctx, json);

View file

@ -53,7 +53,7 @@ CommandParse(char *cmd)
switch (state) switch (state)
{ {
case STATE_WHITE: case STATE_WHITE:
if (!isblank(c)) if (!isblank((int) c))
{ {
state = STATE_NAME; state = STATE_NAME;
namestart = cur; namestart = cur;
@ -84,7 +84,7 @@ CommandParse(char *cmd)
{ {
char c = *cur; char c = *cur;
char cb[2] = { c, '\0' }; char cb[2] = { c, '\0' };
if ((type && c == char_type) || (!type && isblank(c))) if ((type && c == char_type) || (!type && isblank((int) c)))
{ {
break; break;
} }

View file

@ -80,7 +80,7 @@ Main(Array *args, HashMap *env)
); );
ParseePrintASCII(); ParseePrintASCII();
Log(LOG_INFO, "======================="); Log(LOG_INFO, "=======================");
Log(LOG_INFO, "(C)opyright 2024 LDA"); Log(LOG_INFO, "(C)opyright 2024 LDA and other contributors");
Log(LOG_INFO, "(This program is free software, see LICENSE.)"); Log(LOG_INFO, "(This program is free software, see LICENSE.)");
#ifdef PLATFORM_IPHONE #ifdef PLATFORM_IPHONE

View file

@ -12,8 +12,6 @@
#include <Matrix.h> #include <Matrix.h>
#include <AS.h> #include <AS.h>
#include <ctype.h>
static const char * static const char *
GetXMPPInformation(ParseeData *data, HashMap *event, char **from, char **to); GetXMPPInformation(ParseeData *data, HashMap *event, char **from, char **to);

View file

@ -165,7 +165,7 @@ ParseeEncodeJID(const ParseeConfig *c, char *jid, bool trim)
/* RID: Break everything and die. */ /* RID: Break everything and die. */
break; break;
} }
if (islower(*cs) || isalnum(*cs) || *cs == '_' || if (islower((int) *cs) || isalnum((int) *cs) || *cs == '_' ||
*cs == '=' || *cs == '-' || *cs == '/' || *cs == '=' || *cs == '-' || *cs == '/' ||
*cs == '+' || *cs == '.') *cs == '+' || *cs == '.')
{ {

View file

@ -7,7 +7,6 @@
#include <stdbool.h> #include <stdbool.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
char ** char **
StrSplitLines(char *text) StrSplitLines(char *text)

View file

@ -87,7 +87,7 @@ DecodeQuote(StringRect rect, size_t *skip)
* > four but that's for Nerds * > four but that's for Nerds
* > seasons See, Touhou reference! * > seasons See, Touhou reference!
* concealing!) */ * concealing!) */
while ((ch = StrGet(&rect, lines - 1, shift_by)) && isspace(ch)) while ((ch = StrGet(&rect, lines - 1, shift_by)) && isspace((int) ch))
{ {
shift_by++; shift_by++;
} }
@ -132,7 +132,7 @@ DecodeSpan(StringRect rect, char del, size_t *skip)
{ {
return StrFullRect(NULL); return StrFullRect(NULL);
} }
if (!ret.source_lines && isspace(c)) if (!ret.source_lines && isspace((int) c))
{ {
return StrFullRect(NULL); return StrFullRect(NULL);
} }

View file

@ -337,8 +337,8 @@ seekback:
return ret; return ret;
} }
#define IsNamestart(c) ((c == ':') || isalpha(c) || (c == '_')) #define IsNamestart(c) ((c == ':') || isalpha((int) c) || (c == '_'))
#define IsNamepart(c) (IsNamestart(c) || (c == '-') || isdigit(c)) #define IsNamepart(c) (IsNamestart(c) || (c == '-') || isdigit((int) c))
static char * static char *
XMLParseName(XMLexer *lexer) XMLParseName(XMLexer *lexer)
{ {

View file

@ -4,7 +4,6 @@
#include <pthread.h> #include <pthread.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include <time.h> #include <time.h>

View file

@ -32,7 +32,7 @@ TrimBase64(char *b64)
while (*b64) while (*b64)
{ {
char ch[2] = { *b64, 0 }; char ch[2] = { *b64, 0 };
if (isspace(*b64)) if (isspace((int) *b64))
{ {
b64++; b64++;
continue; continue;

View file

@ -83,7 +83,7 @@ ParseAyadoc(char *raw)
if (!strncmp(start, " *", 2) || !strncmp(start, "*", 1)) if (!strncmp(start, " *", 2) || !strncmp(start, "*", 1))
{ {
start += 1 + (*start == ' '); start += 1 + (*start == ' ');
while (start && isspace(*start)) while (start && isspace((int) *start))
{ {
start++; start++;
} }
@ -112,7 +112,7 @@ ParseAyadoc(char *raw)
char *val = del ? del + 1 : NULL; char *val = del ? del + 1 : NULL;
if (del && strlen(del) >= 1) if (del && strlen(del) >= 1)
{ {
while (*val && isspace(*val)) while (*val && isspace((int) *val))
{ {
val++; val++;
} }
@ -214,7 +214,7 @@ HandleSeeValue(Stream *out, AyadocComment *aya, HeaderDeclaration d, char *field
{ \ { \
char *temporary, *field = NULL, *index; \ char *temporary, *field = NULL, *index; \
char *last_char; \ char *last_char; \
while (*start_of_arg && isspace(*start_of_arg)) \ while (*start_of_arg && isspace((int) *start_of_arg)) \
{ \ { \
start_of_arg++; \ start_of_arg++; \
} \ } \
@ -230,7 +230,7 @@ HandleSeeValue(Stream *out, AyadocComment *aya, HeaderDeclaration d, char *field
\ \
/* Trim out spaces */ \ /* Trim out spaces */ \
last_char = separator - 1; \ last_char = separator - 1; \
while (*last_char && isspace(*last_char)) \ while (*last_char && isspace((int) *last_char)) \
{ \ { \
last_char--; \ last_char--; \
} \ } \