version 1.10, 2003/09/26 22:24:09 |
version 1.11, 2006/03/10 19:14:58 |
|
|
#include <unistd.h> |
#include <unistd.h> |
|
|
void c_columnate(void); |
void c_columnate(void); |
void *emalloc(int); |
void *emalloc(size_t); |
void input(FILE *); |
void input(FILE *); |
void maketbl(void); |
void maketbl(void); |
void print(void); |
void print(void); |
|
|
err(1, NULL); |
err(1, NULL); |
cols = cols2; |
cols = cols2; |
lens = lens2; |
lens = lens2; |
memset((char *)lens + maxcols * sizeof(int), |
memset(lens + maxcols, 0, |
0, DEFCOLS * sizeof(int)); |
DEFCOLS * sizeof(int)); |
maxcols += DEFCOLS; |
maxcols += DEFCOLS; |
} |
} |
t->list = emalloc(coloff * sizeof(char *)); |
t->list = emalloc(coloff * sizeof(char *)); |
|
|
void |
void |
input(FILE *fp) |
input(FILE *fp) |
{ |
{ |
static int maxentry; |
static size_t maxentry; |
int len; |
int len; |
char *p, buf[MAXLINELEN]; |
char *p, buf[MAXLINELEN]; |
|
|
|
|
if (maxlength < len) |
if (maxlength < len) |
maxlength = len; |
maxlength = len; |
if (entries == maxentry) { |
if (entries == maxentry) { |
maxentry += DEFNUM; |
char **nlist; |
if (!(list = realloc(list, |
size_t nsize = maxentry + DEFNUM; |
(u_int)maxentry * sizeof(char *)))) |
|
|
if (!(nlist = realloc(list, nsize * sizeof(char *)))) |
err(1, NULL); |
err(1, NULL); |
|
list = nlist; |
|
maxentry = nsize; |
} |
} |
list[entries++] = strdup(buf); |
if (!(list[entries++] = strdup(buf))) |
|
err(1, NULL); |
} |
} |
} |
} |
|
|
void * |
void * |
emalloc(int size) |
emalloc(size_t size) |
{ |
{ |
char *p; |
void *p; |
|
|
if (!(p = malloc(size))) |
if (!(p = malloc(size))) |
err(1, NULL); |
err(1, NULL); |