"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "extension/filefuncs.c" between
gawk-5.0.1.tar.xz and gawk-5.1.0.tar.xz

About: GNU awk - pattern scanning and processing language.

filefuncs.c  (gawk-5.0.1.tar.xz):filefuncs.c  (gawk-5.1.0.tar.xz)
skipping to change at line 13 skipping to change at line 13
* to the file system. * to the file system.
* *
* Arnold Robbins, update for 3.1, Mon Nov 23 12:53:39 EST 1998 * Arnold Robbins, update for 3.1, Mon Nov 23 12:53:39 EST 1998
* Arnold Robbins and John Haque, update for 3.1.4, applied Mon Jun 14 13:55:30 IDT 2004 * Arnold Robbins and John Haque, update for 3.1.4, applied Mon Jun 14 13:55:30 IDT 2004
* Arnold Robbins and Andrew Schorr, revised for new extension API, May 2012. * Arnold Robbins and Andrew Schorr, revised for new extension API, May 2012.
* Arnold Robbins, add fts(), August 2012 * Arnold Robbins, add fts(), August 2012
* Arnold Robbins, add statvfs(), November 2015 * Arnold Robbins, add statvfs(), November 2015
*/ */
/* /*
* Copyright (C) 2001, 2004, 2005, 2010-2018 * Copyright (C) 2001, 2004, 2005, 2010-2020,
* the Free Software Foundation, Inc. * the Free Software Foundation, Inc.
* *
* This file is part of GAWK, the GNU implementation of the * This file is part of GAWK, the GNU implementation of the
* AWK Programming Language. * AWK Programming Language.
* *
* GAWK is free software; you can redistribute it and/or modify * GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
skipping to change at line 472 skipping to change at line 472
awk_value_t file_param, array_param; awk_value_t file_param, array_param;
char *name; char *name;
awk_array_t array; awk_array_t array;
int ret; int ret;
struct stat sbuf; struct stat sbuf;
int (*statfunc)(const char *path, struct stat *sbuf) = lstat; /* defaul t */ int (*statfunc)(const char *path, struct stat *sbuf) = lstat; /* defaul t */
assert(result != NULL); assert(result != NULL);
/* file is first arg, array to hold results is second */ /* file is first arg, array to hold results is second */
if ( ! get_argument(0, AWK_STRING, & file_param) if (! get_argument(0, AWK_STRING, & file_param)) {
|| ! get_argument(1, AWK_ARRAY, & array_param)) { warning(ext_id, _("stat: first argument is not a string"));
warning(ext_id, _("stat: bad parameters")); return make_number(-1, result);
}
if (! get_argument(1, AWK_ARRAY, & array_param)) {
warning(ext_id, _("stat: second argument is not an array"));
return make_number(-1, result); return make_number(-1, result);
} }
if (nargs == 3) { if (nargs == 3) {
statfunc = stat; statfunc = stat;
} }
name = file_param.str_value.str; name = file_param.str_value.str;
array = array_param.array_cookie; array = array_param.array_cookie;
skipping to change at line 528 skipping to change at line 532
warning(ext_id, _("stat: bad parameters")); warning(ext_id, _("stat: bad parameters"));
return make_number(-1, result); return make_number(-1, result);
} }
name = file_param.str_value.str; name = file_param.str_value.str;
array = array_param.array_cookie; array = array_param.array_cookie;
/* always empty out the array */ /* always empty out the array */
clear_array(array); clear_array(array);
/* stat the file; if error, set ERRNO and return */ /* statvfs the filesystem; if error, set ERRNO and return */
ret = statvfs(name, & vfsbuf); ret = statvfs(name, & vfsbuf);
if (ret < 0) { if (ret < 0) {
update_ERRNO_int(errno); update_ERRNO_int(errno);
return make_number(ret, result); return make_number(ret, result);
} }
array_set_numeric(array, "bsize", vfsbuf.f_bsize); /* filesystem blo ck size */ array_set_numeric(array, "bsize", vfsbuf.f_bsize); /* filesystem blo ck size */
array_set_numeric(array, "frsize", vfsbuf.f_frsize); /* fragment size */ array_set_numeric(array, "frsize", vfsbuf.f_frsize); /* fragment size */
array_set_numeric(array, "blocks", vfsbuf.f_blocks); /* size of fs in f_frsize units */ array_set_numeric(array, "blocks", vfsbuf.f_blocks); /* size of fs in f_frsize units */
array_set_numeric(array, "bfree", vfsbuf.f_bfree); /* # free blocks */ array_set_numeric(array, "bfree", vfsbuf.f_bfree); /* # free blocks */
skipping to change at line 622 skipping to change at line 626
/* fill_stat_element --- fill in stat element of array */ /* fill_stat_element --- fill in stat element of array */
static void static void
fill_stat_element(awk_array_t element_array, const char *name, struct stat *sbuf ) fill_stat_element(awk_array_t element_array, const char *name, struct stat *sbuf )
{ {
awk_value_t index, value; awk_value_t index, value;
awk_array_t stat_array; awk_array_t stat_array;
stat_array = create_array(); stat_array = create_array();
if (stat_array == NULL) { if (stat_array == NULL) {
warning(ext_id, _("fill_stat_element: could not create array")); warning(ext_id, _("fill_stat_element: could not create array, out of memory"));
fts_errors++; fts_errors++;
return; return;
} }
fill_stat_array(name, stat_array, sbuf); fill_stat_array(name, stat_array, sbuf);
(void) make_const_string("stat", 4, & index); (void) make_const_string("stat", 4, & index);
value.val_type = AWK_ARRAY; value.val_type = AWK_ARRAY;
value.array_cookie = stat_array; value.array_cookie = stat_array;
if (! set_array_element(element_array, & index, & value)) { if (! set_array_element(element_array, & index, & value)) {
warning(ext_id, _("fill_stat_element: could not set element")); warning(ext_id, _("fill_stat_element: could not set element"));
fts_errors++; fts_errors++;
skipping to change at line 841 skipping to change at line 845
FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOCHDIR | FTS_PHYSICAL FTS_COMFOLLOW | FTS_LOGICAL | FTS_NOCHDIR | FTS_PHYSICAL
| FTS_SEEDOT | FTS_XDEV | FTS_SKIP); | FTS_SEEDOT | FTS_XDEV | FTS_SKIP);
assert(result != NULL); assert(result != NULL);
fts_errors = 0; /* ensure a fresh start */ fts_errors = 0; /* ensure a fresh start */
if (nargs > 3) if (nargs > 3)
lintwarn(ext_id, _("fts: called with incorrect number of argument s, expecting 3")); lintwarn(ext_id, _("fts: called with incorrect number of argument s, expecting 3"));
if (! get_argument(0, AWK_ARRAY, & pathlist)) { if (! get_argument(0, AWK_ARRAY, & pathlist)) {
warning(ext_id, _("fts: bad first parameter")); warning(ext_id, _("fts: first argument is not an array"));
update_ERRNO_int(EINVAL); update_ERRNO_int(EINVAL);
goto out; goto out;
} }
if (! get_argument(1, AWK_NUMBER, & flagval)) { if (! get_argument(1, AWK_NUMBER, & flagval)) {
warning(ext_id, _("fts: bad second parameter")); warning(ext_id, _("fts: second argument is not a number"));
update_ERRNO_int(EINVAL); update_ERRNO_int(EINVAL);
goto out; goto out;
} }
if (! get_argument(2, AWK_ARRAY, & dest)) { if (! get_argument(2, AWK_ARRAY, & dest)) {
warning(ext_id, _("fts: bad third parameter")); warning(ext_id, _("fts: third argument is not an array"));
update_ERRNO_int(EINVAL); update_ERRNO_int(EINVAL);
goto out; goto out;
} }
/* flatten pathlist */ /* flatten pathlist */
if (! flatten_array(pathlist.array_cookie, & path_array)) { if (! flatten_array(pathlist.array_cookie, & path_array)) {
warning(ext_id, _("fts: could not flatten array\n")); warning(ext_id, _("fts: could not flatten array\n"));
goto out; goto out;
} }
skipping to change at line 892 skipping to change at line 896
/* make pathvector */ /* make pathvector */
count = path_array->count + 1; count = path_array->count + 1;
ezalloc(pathvector, char **, count * sizeof(char *), "do_fts"); ezalloc(pathvector, char **, count * sizeof(char *), "do_fts");
/* fill it in */ /* fill it in */
count--; /* ignore final NULL at end of vector */ count--; /* ignore final NULL at end of vector */
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
pathvector[i] = path_array->elements[i].value.str_value.str; pathvector[i] = path_array->elements[i].value.str_value.str;
/* clear dest array */ /* clear dest array */
if (! clear_array(dest.array_cookie)) { assert(clear_array(dest.array_cookie));
warning(ext_id, _("fts: clear_array() failed\n"));
goto out;
}
/* let's do it! */ /* let's do it! */
if ((hierarchy = fts_open(pathvector, flags, NULL)) != NULL) { if ((hierarchy = fts_open(pathvector, flags, NULL)) != NULL) {
process(hierarchy, dest.array_cookie, (flags & FTS_SEEDOT) != 0, (flags & FTS_SKIP) != 0); process(hierarchy, dest.array_cookie, (flags & FTS_SEEDOT) != 0, (flags & FTS_SKIP) != 0);
fts_close(hierarchy); fts_close(hierarchy);
if (fts_errors == 0) if (fts_errors == 0)
ret = 0; ret = 0;
} else } else
update_ERRNO_int(errno); update_ERRNO_int(errno);
 End of changes. 8 change blocks. 
13 lines changed or deleted 14 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)