remove special case stralloc textcode functions

write generic stralloc and array textcode wrapper functions
change textcode API to use long instead of int
add cescape fmt and scan functions to textcode
add fmt_foldwhitespace to textcode
This commit is contained in:
leitner
2003-09-19 19:08:13 +00:00
parent e86a457f5c
commit a8f6a1c121
40 changed files with 218 additions and 477 deletions

View File

@@ -0,0 +1,15 @@
#include "array.h"
#include "textcode.h"
void fmt_tofrom_array(unsigned long (*func)(char*,const char*,unsigned long),
array* dest,array* src) {
unsigned long needed;
char* x;
if (array_failed(dest) || array_failed(src)) { array_fail(dest); return; }
needed=func(0,array_start(src),array_bytes(src));
if (array_allocate(dest,1,array_bytes(dest)+needed-1)) {
x=array_start(dest)+array_bytes(dest)-needed;
func(x,array_start(src),array_bytes(src));
} else
array_fail(dest);
}