Rename plfunc/plfunc to plfunc/general.

Fix new docTexts cleanup.
This commit is contained in:
Sage Vaillancourt 2022-04-25 16:30:30 -04:00 committed by Sage Vaillancourt
parent 08bf35940d
commit b39db34208
5 changed files with 18 additions and 9 deletions

View File

@ -1,7 +1,7 @@
exe = pl
base_files = main.c pebblisp.c tokens.c object.c env.c hash.c
func_files = plfunc/web.c plfunc/plfunc.c plfunc/threads.c plfunc/plstring.c plfunc/pc.c
func_files = plfunc/web.c plfunc/general.c plfunc/threads.c plfunc/plstring.c plfunc/pc.c
files:= $(base_files) $(func_files)
libs = -lreadline -lmicrohttpd -lpthread

View File

@ -7,7 +7,7 @@
#include "pebblisp.h"
#include "plfunc/web.h"
#include "plfunc/threads.h"
#include "plfunc/plfunc.h"
#include "plfunc/general.h"
#include "plfunc/pc.h"
#include "plfunc/plstring.h"
@ -480,10 +480,12 @@ int runTest(const char* test, const char* expected, int detailed)
size_t length;
char* result = stringObj(&o, &length);
cleanObject(&o);
int expectedLen = 0;
int expectedLen = 0; // Don't count anything after a semicolon
while (expected[expectedLen] && expected[expectedLen] != ';') {
expectedLen++;
}
int ret;
if (strncmp(result, expected, expectedLen) != 0) {
ret = 0;
@ -491,10 +493,10 @@ int runTest(const char* test, const char* expected, int detailed)
printf("%s\n", test);
printf("Expected '%s' but received '%s'\n", expected, result);
} else {
ret = 1;
if (detailed) {
printf("✓");
}
ret = 1;
}
free(result);
deleteEnv(&env);

View File

@ -421,7 +421,14 @@ void cleanObject(Object* target)
if (!lambdaRefs(target)) {
cleanObject(&target->lambda->params);
cleanObject(&target->lambda->body);
char** docTexts = lambdaDocs(target);
if (docTexts) {
while (*docTexts) {
free(*docTexts);
docTexts++;
}
free(lambdaDocs(target));
}
free(target->lambda);
}
return;

View File

@ -2,7 +2,7 @@
#include <string.h>
#include <time.h>
#include "plfunc.h"
#include "general.h"
Object reduce(Object* params, unused int length, struct Environment* env)
{

View File

@ -1,5 +1,5 @@
#ifndef PEBBLISP_PLFUNC_H
#define PEBBLISP_PLFUNC_H
#ifndef PEBBLISP_GENERAL_H
#define PEBBLISP_GENERAL_H
#include "../pebblisp.h"
@ -181,4 +181,4 @@ tfn(getTime, "time",
"Get a struct of the current time with fields (minute hour sec)."
);
#endif // PEBBLISP_PLFUNC_H
#endif // PEBBLISP_GENERAL_H