diff options
Diffstat (limited to 'extension')
-rw-r--r-- | extension/ChangeLog | 6 | ||||
-rw-r--r-- | extension/bindarr.c | 10 | ||||
-rw-r--r-- | extension/fileop.c | 70 | ||||
-rw-r--r-- | extension/sparr.c | 13 | ||||
-rwxr-xr-x | extension/steps | 19 | ||||
-rw-r--r-- | extension/testsparr.awk | 1 |
6 files changed, 61 insertions, 58 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog index 4089185e..932eb3a7 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,9 @@ +2012-11-26 Arnold D. Robbins <arnold@skeeve.com> + + * bindarr.c, fileop.c, sparr.c: Make them compile. + * steps: Reinstated and updated. + * testsparr.awk: Add call to extension(). + 2011-05-03 John Haque <j.eh@mchsi.com> * fileop.c, record.awk, testrecord.sh: New files. diff --git a/extension/bindarr.c b/extension/bindarr.c index 9f8e090c..60959903 100644 --- a/extension/bindarr.c +++ b/extension/bindarr.c @@ -203,7 +203,7 @@ do_bind_array(int nargs) array_t *aq; char *aname; - symbol = get_array_argument(0, FALSE); + symbol = get_array_argument(0, false); if (symbol->array_funcs == bind_array_func) fatal(_("bind_array: array `%s' already bound"), array_vname(symbol)); @@ -212,7 +212,7 @@ do_bind_array(int nargs) emalloc(aq, array_t *, sizeof(array_t), "do_bind_array"); memset(aq, '\0', sizeof(array_t)); - t = get_array_argument(1, FALSE); + t = get_array_argument(1, false); for (i = 0; i < sizeof(bfn)/sizeof(char *); i++) { NODE *subs, *val, *f; @@ -265,7 +265,7 @@ do_unbind_array(int nargs) NODE *symbol, *xn, *td; array_t *aq; - symbol = get_array_argument(0, FALSE); + symbol = get_array_argument(0, false); if (symbol->array_funcs != bind_array_func) fatal(_("unbind_array: `%s' is not a bound array"), array_vname(symbol)); @@ -341,7 +341,7 @@ call_func(NODE *func, NODE **arg, int arg_count) NODE * dlload(NODE *obj, void *dl) { - make_builtin("bind_array", do_bind_array, 2); - make_builtin("unbind_array", do_unbind_array, 1); + make_old_builtin("bind_array", do_bind_array, 2); + make_old_builtin("unbind_array", do_unbind_array, 1); return make_number((AWKNUM) 0); } diff --git a/extension/fileop.c b/extension/fileop.c index 947c683b..86f62576 100644 --- a/extension/fileop.c +++ b/extension/fileop.c @@ -49,16 +49,16 @@ do_fread(int nargs) file_t *f; char *rbuf; - f = file_open("fread", nargs, TRUE); + f = file_open("fread", nargs, true); - arg = get_scalar_argument(2, FALSE); + arg = get_scalar_argument(2, false); force_number(arg); rlen = get_number_ui(arg); emalloc(rbuf, char *, rlen + 2, "do_fread"); if ((count = fread(rbuf, 1, rlen, f->fp)) < rlen) { if (! feof(f->fp)) - update_ERRNO(); + update_ERRNO_int(errno); } return make_str_node(rbuf, count, ALREADY_MALLOCED); } @@ -72,14 +72,14 @@ do_fwrite(int nargs) file_t *f; size_t count = 0; - f = file_open("fwrite", nargs, TRUE); + f = file_open("fwrite", nargs, true); - arg = get_scalar_argument(2, FALSE); + arg = get_scalar_argument(2, false); force_string(arg); if (arg->stlen > 0) { count = fwrite(arg->stptr, 1, arg->stlen, f->fp); if (count < arg->stlen) - update_ERRNO(); + update_ERRNO_int(errno); } return make_number(count); } @@ -94,13 +94,13 @@ do_fseek(int nargs) file_t *f; int whence = 0, ret = 0; - f = file_open("fseek", nargs, TRUE); + f = file_open("fseek", nargs, true); - arg = get_scalar_argument(2, FALSE); + arg = get_scalar_argument(2, false); force_number(arg); offset = get_number_si(arg); - arg = get_scalar_argument(3, FALSE); + arg = get_scalar_argument(3, false); force_string(arg); if (strcasecmp(arg->stptr, "SEEK_SET") == 0) whence = SEEK_SET; @@ -113,7 +113,7 @@ do_fseek(int nargs) (int) arg->stlen, arg->stptr); if (fseek(f->fp, offset, whence) < 0) { - update_ERRNO(); + update_ERRNO_int(errno); ret = -1; } return make_number(ret); @@ -129,12 +129,12 @@ do_ftruncate(int nargs) off_t len; int ret = 0; - f = file_open("ftruncate", nargs, TRUE); - arg = get_scalar_argument(2, FALSE); + f = file_open("ftruncate", nargs, true); + arg = get_scalar_argument(2, false); force_number(arg); len = (off_t) get_number_si(arg); if (ftruncate(fileno(f->fp), len) < 0) { - update_ERRNO(); + update_ERRNO_int(errno); ret = -1; } return make_number(ret); @@ -148,12 +148,12 @@ do_unlink(int nargs) NODE *file; int ret = 0; - file = get_scalar_argument(0, FALSE); + file = get_scalar_argument(0, false); force_string(file); if (file->stlen == 0) fatal(_("unlink: filename has empty string value")); if (unlink(file->stptr) < 0) { - update_ERRNO(); + update_ERRNO_int(errno); ret = -1; } return make_number(ret); @@ -167,11 +167,11 @@ do_flush(int nargs) file_t *f; int status = -1; - f = file_open("flush", nargs, FALSE); + f = file_open("flush", nargs, false); if (f != NULL) { status = fflush(f->fp); if (status != 0) - update_ERRNO(); + update_ERRNO_int(errno); } return make_number(status); } @@ -184,11 +184,11 @@ do_fclose(int nargs) file_t *f; int status = -1; - f = file_open("fclose", nargs, FALSE); + f = file_open("fclose", nargs, false); if (f != NULL) { status = fclose(f->fp); if (status != 0) - update_ERRNO(); + update_ERRNO_int(errno); assert(files == f); files = f->next; efree(f); @@ -205,18 +205,18 @@ do_filesize(int nargs) struct stat sbuf; AWKNUM d = -1.0; - file = get_scalar_argument(0, FALSE); + file = get_scalar_argument(0, false); force_string(file); if (file->stlen == 0) fatal(_("filesize: filename has empty string value")); if (stat(file->stptr, & sbuf) < 0) { - update_ERRNO(); + update_ERRNO_int(errno); goto ferror; } if ((sbuf.st_mode & S_IFMT) != S_IFREG) { errno = EINVAL; - update_ERRNO(); + update_ERRNO_int(errno); goto ferror; } d = sbuf.st_size; @@ -234,14 +234,14 @@ do_file_exists(int nargs) struct stat sbuf; int ret = 1; - file = get_scalar_argument(0, FALSE); + file = get_scalar_argument(0, false); force_string(file); if (file->stlen == 0) fatal(_("file_exists: filename has empty string value")); if (stat(file->stptr, & sbuf) < 0) { if (errno != ENOENT) - update_ERRNO(); + update_ERRNO_int(errno); ret = 0; } return make_number(ret); @@ -262,9 +262,9 @@ file_open(const char *builtin_name, int nargs, int do_open) if (nargs < 2) cant_happen(); - file = get_scalar_argument(0, FALSE); + file = get_scalar_argument(0, false); force_string(file); - mode = get_scalar_argument(1, TRUE); + mode = get_scalar_argument(1, true); force_string(mode); if (file->stlen == 0) @@ -366,15 +366,15 @@ mode2flags(const char *mode) NODE * dlload(NODE *tree, void *dl) { - make_builtin("fseek", do_fseek, 4); - make_builtin("fread", do_fread, 3); - make_builtin("fwrite", do_fwrite, 3); - make_builtin("flush", do_flush, 2); - make_builtin("filesize", do_filesize, 1); - make_builtin("file_exists", do_file_exists, 1); - make_builtin("fclose", do_fclose, 2); - make_builtin("ftruncate", do_ftruncate, 3); - make_builtin("unlink", do_unlink, 1); + make_old_builtin("fseek", do_fseek, 4); + make_old_builtin("fread", do_fread, 3); + make_old_builtin("fwrite", do_fwrite, 3); + make_old_builtin("flush", do_flush, 2); + make_old_builtin("filesize", do_filesize, 1); + make_old_builtin("file_exists", do_file_exists, 1); + make_old_builtin("fclose", do_fclose, 2); + make_old_builtin("ftruncate", do_ftruncate, 3); + make_old_builtin("unlink", do_unlink, 1); return make_number((AWKNUM) 0); } diff --git a/extension/sparr.c b/extension/sparr.c index e986eb1e..a3d06e66 100644 --- a/extension/sparr.c +++ b/extension/sparr.c @@ -47,7 +47,7 @@ install_array(const char *name) r = install_symbol(estrdup(name, strlen(name)), Node_var_array); switch (r->type) { case Node_var_new: - r = force_array(r, FALSE); + r = force_array(r, false); /* fall through */ case Node_var_array: assoc_clear(r); @@ -79,7 +79,7 @@ store_SYS(NODE *symbol, NODE *subs, NODE *val, void *data) if (subs != NULL && val != NULL && val->type == Node_val) { force_string(subs); if (strcmp(subs->stptr, "readline") == 0) { - sd->load_file = TRUE; + sd->load_file = true; unref(sd->filename); sd->filename = dupnode(val); } @@ -95,7 +95,8 @@ load_READLINE(NODE *symbol, void *data) NODE *file, *tmp; FILE *fp; static char linebuf[BUFSIZ]; - int i, long_line = FALSE; + int i; + bool long_line = false; if (! sd->load_file) /* non-existent SYS["readline"] or already loaded */ return; @@ -122,7 +123,7 @@ load_READLINE(NODE *symbol, void *data) linebuf[sz - 1] = '\0'; sz--; if (long_line) { - long_line = FALSE; + long_line = false; i--; continue; } @@ -133,7 +134,7 @@ load_READLINE(NODE *symbol, void *data) if (do_lint) lintwarn(_("file `%s' does not end in newline or line # `%d' is too long"), file->stptr, i); - long_line = TRUE; + long_line = true; } tmp = make_number(i); @@ -143,7 +144,7 @@ load_READLINE(NODE *symbol, void *data) *lhs = make_string(linebuf, sz); } fclose(fp); - sd->load_file = FALSE; /* don't load this file again */ + sd->load_file = false; /* don't load this file again */ } /* dlload --- load this library */ diff --git a/extension/steps b/extension/steps index 168ec39e..3e8070d6 100755 --- a/extension/steps +++ b/extension/steps @@ -1,15 +1,10 @@ # what to do under linux to make dl.so -# Tue Nov 24 15:04:14 EST 1998 -# Sun Aug 26 16:03:58 IDT 2001 -# Sun Apr 28 15:59:57 IDT 2002 -# Mon Jun 21 17:03:37 IDT 2004 -# Fri May 15 15:48:45 IDT 2009 # Sun Nov 25 21:40:49 IST 2012 -gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. spec_array.c -gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. sparr.c -gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. bindarr.c -gcc -fPIC -shared -Wall -DHAVE_CONFIG_H -c -O -g -I.. fileop.c -ld -o sparr.so -shared sparr.o spec_array.o -ld -o bindarr.so -shared bindarr.o -ld -o fileop.so -shared fileop.o +gcc -fPIC -shared -Wall -DGAWK -DHAVE_CONFIG_H -c -O -g -I.. spec_array.c +gcc -fPIC -shared -Wall -DGAWK -DHAVE_CONFIG_H -c -O -g -I.. sparr.c +gcc -fPIC -shared -Wall -DGAWK -DHAVE_CONFIG_H -c -O -g -I.. bindarr.c +gcc -fPIC -shared -Wall -DGAWK -DHAVE_CONFIG_H -c -O -g -I.. fileop.c +gcc -o sparr.so -shared sparr.o spec_array.o +gcc -o bindarr.so -shared bindarr.o +gcc -o fileop.so -shared fileop.o diff --git a/extension/testsparr.awk b/extension/testsparr.awk index b31409f2..648a21a2 100644 --- a/extension/testsparr.awk +++ b/extension/testsparr.awk @@ -1,5 +1,6 @@ # ../gawk -lsparr -f testsparr.awk BEGIN { + extension("sparr") print SYS["time"] SYS["readline"] = "sparr.c"; printf("File %s has %d lines\n", SYS["readline"], length(READLINE)) |