aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/gawk.info178
-rw-r--r--doc/gawk.texi9
-rw-r--r--doc/gawktexi.in9
-rw-r--r--extension/ChangeLog7
-rw-r--r--extension/configh.in3
-rwxr-xr-xextension/configure2
-rw-r--r--extension/configure.ac2
-rw-r--r--extension/filefuncs.c31
9 files changed, 159 insertions, 87 deletions
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 34cf4155..fc2a1354 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2013-05-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in (Internal File Description): Add "devbsize" element
+ to stat data array.
+
2013-05-27 Arnold D. Robbins <arnold@skeeve.com>
* gawtexi.in: Sample filefuncs.c extension code: Change test from
diff --git a/doc/gawk.info b/doc/gawk.info
index a18ac42d..bc407397 100644
--- a/doc/gawk.info
+++ b/doc/gawk.info
@@ -23659,6 +23659,14 @@ appropriate information:
`"symlink"'
The file is a symbolic link.
+`"devbsize"'
+ The size of a block for the element indexed by `"blocks"'. This
+ information is derived from either the `DEV_BSIZE' constant
+ defined in `<sys/param.h>' on most systems, or the `S_BLKSIZE'
+ constant in `<sys/stat.h>' on BSD systems. For some other
+ systems, "a priori" knowledge is used to provide a value. Where no
+ value can be determined, it defaults to 512.
+
Several additional elements may be present depending upon the
operating system and the type of the file. You can test for them in
your `awk' program by using the `in' operator (*note Reference to
@@ -32493,90 +32501,90 @@ Node: Extension API Boilerplate947271
Node: Finding Extensions951075
Node: Extension Example951635
Node: Internal File Description952366
-Node: Internal File Ops956054
-Ref: Internal File Ops-Footnote-1967562
-Node: Using Internal File Ops967702
-Ref: Using Internal File Ops-Footnote-1970055
-Node: Extension Samples970321
-Node: Extension Sample File Functions971845
-Node: Extension Sample Fnmatch980332
-Node: Extension Sample Fork982058
-Node: Extension Sample Inplace983276
-Node: Extension Sample Ord985054
-Node: Extension Sample Readdir985890
-Node: Extension Sample Revout987422
-Node: Extension Sample Rev2way988015
-Node: Extension Sample Read write array988705
-Node: Extension Sample Readfile990588
-Node: Extension Sample API Tests991406
-Node: Extension Sample Time991931
-Node: gawkextlib993295
-Node: Language History996055
-Node: V7/SVR3.1997577
-Node: SVR4999898
-Node: POSIX1001340
-Node: BTL1002726
-Node: POSIX/GNU1003460
-Node: Common Extensions1008995
-Node: Ranges and Locales1010301
-Ref: Ranges and Locales-Footnote-11014919
-Ref: Ranges and Locales-Footnote-21014946
-Ref: Ranges and Locales-Footnote-31015206
-Node: Contributors1015427
-Node: Installation1020306
-Node: Gawk Distribution1021200
-Node: Getting1021684
-Node: Extracting1022510
-Node: Distribution contents1024202
-Node: Unix Installation1029463
-Node: Quick Installation1030080
-Node: Additional Configuration Options1032524
-Node: Configuration Philosophy1034001
-Node: Non-Unix Installation1036355
-Node: PC Installation1036813
-Node: PC Binary Installation1038112
-Node: PC Compiling1039960
-Node: PC Testing1042904
-Node: PC Using1044080
-Node: Cygwin1048265
-Node: MSYS1049265
-Node: VMS Installation1049779
-Node: VMS Compilation1050382
-Ref: VMS Compilation-Footnote-11051389
-Node: VMS Installation Details1051447
-Node: VMS Running1053082
-Node: VMS Old Gawk1054689
-Node: Bugs1055163
-Node: Other Versions1059015
-Node: Notes1064616
-Node: Compatibility Mode1065416
-Node: Additions1066199
-Node: Accessing The Source1067126
-Node: Adding Code1068566
-Node: New Ports1074611
-Node: Derived Files1078746
-Ref: Derived Files-Footnote-11084067
-Ref: Derived Files-Footnote-21084101
-Ref: Derived Files-Footnote-31084701
-Node: Future Extensions1084799
-Node: Implementation Limitations1085380
-Node: Extension Design1086632
-Node: Old Extension Problems1087786
-Ref: Old Extension Problems-Footnote-11089294
-Node: Extension New Mechanism Goals1089351
-Ref: Extension New Mechanism Goals-Footnote-11092717
-Node: Extension Other Design Decisions1092903
-Node: Extension Future Growth1095009
-Node: Old Extension Mechanism1095845
-Node: Basic Concepts1097585
-Node: Basic High Level1098266
-Ref: figure-general-flow1098537
-Ref: figure-process-flow1099136
-Ref: Basic High Level-Footnote-11102365
-Node: Basic Data Typing1102550
-Node: Glossary1105905
-Node: Copying1131367
-Node: GNU Free Documentation License1168924
-Node: Index1194061
+Node: Internal File Ops956457
+Ref: Internal File Ops-Footnote-1967965
+Node: Using Internal File Ops968105
+Ref: Using Internal File Ops-Footnote-1970458
+Node: Extension Samples970724
+Node: Extension Sample File Functions972248
+Node: Extension Sample Fnmatch980735
+Node: Extension Sample Fork982461
+Node: Extension Sample Inplace983679
+Node: Extension Sample Ord985457
+Node: Extension Sample Readdir986293
+Node: Extension Sample Revout987825
+Node: Extension Sample Rev2way988418
+Node: Extension Sample Read write array989108
+Node: Extension Sample Readfile990991
+Node: Extension Sample API Tests991809
+Node: Extension Sample Time992334
+Node: gawkextlib993698
+Node: Language History996458
+Node: V7/SVR3.1997980
+Node: SVR41000301
+Node: POSIX1001743
+Node: BTL1003129
+Node: POSIX/GNU1003863
+Node: Common Extensions1009398
+Node: Ranges and Locales1010704
+Ref: Ranges and Locales-Footnote-11015322
+Ref: Ranges and Locales-Footnote-21015349
+Ref: Ranges and Locales-Footnote-31015609
+Node: Contributors1015830
+Node: Installation1020709
+Node: Gawk Distribution1021603
+Node: Getting1022087
+Node: Extracting1022913
+Node: Distribution contents1024605
+Node: Unix Installation1029866
+Node: Quick Installation1030483
+Node: Additional Configuration Options1032927
+Node: Configuration Philosophy1034404
+Node: Non-Unix Installation1036758
+Node: PC Installation1037216
+Node: PC Binary Installation1038515
+Node: PC Compiling1040363
+Node: PC Testing1043307
+Node: PC Using1044483
+Node: Cygwin1048668
+Node: MSYS1049668
+Node: VMS Installation1050182
+Node: VMS Compilation1050785
+Ref: VMS Compilation-Footnote-11051792
+Node: VMS Installation Details1051850
+Node: VMS Running1053485
+Node: VMS Old Gawk1055092
+Node: Bugs1055566
+Node: Other Versions1059418
+Node: Notes1065019
+Node: Compatibility Mode1065819
+Node: Additions1066602
+Node: Accessing The Source1067529
+Node: Adding Code1068969
+Node: New Ports1075014
+Node: Derived Files1079149
+Ref: Derived Files-Footnote-11084470
+Ref: Derived Files-Footnote-21084504
+Ref: Derived Files-Footnote-31085104
+Node: Future Extensions1085202
+Node: Implementation Limitations1085783
+Node: Extension Design1087035
+Node: Old Extension Problems1088189
+Ref: Old Extension Problems-Footnote-11089697
+Node: Extension New Mechanism Goals1089754
+Ref: Extension New Mechanism Goals-Footnote-11093120
+Node: Extension Other Design Decisions1093306
+Node: Extension Future Growth1095412
+Node: Old Extension Mechanism1096248
+Node: Basic Concepts1097988
+Node: Basic High Level1098669
+Ref: figure-general-flow1098940
+Ref: figure-process-flow1099539
+Ref: Basic High Level-Footnote-11102768
+Node: Basic Data Typing1102953
+Node: Glossary1106308
+Node: Copying1131770
+Node: GNU Free Documentation License1169327
+Node: Index1194464

End Tag Table
diff --git a/doc/gawk.texi b/doc/gawk.texi
index b6c72540..240669cf 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -31597,6 +31597,15 @@ filesystem.
@item "symlink"
The file is a symbolic link.
@end table
+
+@c 5/2013: Thanks to Corinna Vinschen for this information.
+@item "devbsize"
+The size of a block for the element indexed by @code{"blocks"}.
+This information is derived from either the @code{DEV_BSIZE}
+constant defined in @code{<sys/param.h>} on most systems,
+or the @code{S_BLKSIZE} constant in @code{<sys/stat.h>} on BSD systems.
+For some other systems, @dfn{a priori} knowledge is used to provide
+a value. Where no value can be determined, it defaults to 512.
@end table
Several additional elements may be present depending upon the operating
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index f2bc9c2a..d0356991 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -30746,6 +30746,15 @@ filesystem.
@item "symlink"
The file is a symbolic link.
@end table
+
+@c 5/2013: Thanks to Corinna Vinschen for this information.
+@item "devbsize"
+The size of a block for the element indexed by @code{"blocks"}.
+This information is derived from either the @code{DEV_BSIZE}
+constant defined in @code{<sys/param.h>} on most systems,
+or the @code{S_BLKSIZE} constant in @code{<sys/stat.h>} on BSD systems.
+For some other systems, @dfn{a priori} knowledge is used to provide
+a value. Where no value can be determined, it defaults to 512.
@end table
Several additional elements may be present depending upon the operating
diff --git a/extension/ChangeLog b/extension/ChangeLog
index 4d2d69b8..02b426ee 100644
--- a/extension/ChangeLog
+++ b/extension/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-29 Arnold D. Robbins <arnold@skeeve.com>
+
+ * configure.ac: Add <sys/param.h> header check.
+ * filefuncs.c: Include <sys/param.h> if there.
+ (device_blocksize): New function.
+ (fill_stat_array): Call it.
+
2013-05-27 Arnold D. Robbins <arnold@skeeve.com>
* configure.ac (AC_STRUCT_ST_BLKSIZE): Replaced with call to
diff --git a/extension/configh.in b/extension/configh.in
index ac8ad05f..8da69306 100644
--- a/extension/configh.in
+++ b/extension/configh.in
@@ -90,6 +90,9 @@
/* Define to 1 if `st_blksize' is a member of `struct stat'. */
#undef HAVE_STRUCT_STAT_ST_BLKSIZE
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
/* Define to 1 if you have the <sys/select.h> header file. */
#undef HAVE_SYS_SELECT_H
diff --git a/extension/configure b/extension/configure
index 26cde4b0..1adb8dd5 100755
--- a/extension/configure
+++ b/extension/configure
@@ -13952,7 +13952,7 @@ else
$as_echo "no" >&6; }
fi
-for ac_header in dirent.h fnmatch.h time.h sys/time.h sys/select.h
+for ac_header in dirent.h fnmatch.h time.h sys/time.h sys/select.h sys/param.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
diff --git a/extension/configure.ac b/extension/configure.ac
index 82742860..f5b03e06 100644
--- a/extension/configure.ac
+++ b/extension/configure.ac
@@ -66,7 +66,7 @@ else
AC_MSG_RESULT([no])
fi
-AC_CHECK_HEADERS(dirent.h fnmatch.h time.h sys/time.h sys/select.h)
+AC_CHECK_HEADERS(dirent.h fnmatch.h time.h sys/time.h sys/select.h sys/param.h)
AC_CHECK_FUNCS(fdopendir fnmatch gettimeofday \
getdtablesize nanosleep select GetSystemTimeAsFileTime)
diff --git a/extension/filefuncs.c b/extension/filefuncs.c
index 9d4b2258..0afed056 100644
--- a/extension/filefuncs.c
+++ b/extension/filefuncs.c
@@ -45,6 +45,9 @@
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif /* HAVE_SYS_PARAM_H */
#include "gawkapi.h"
@@ -265,6 +268,31 @@ read_symlink(const char *fname, size_t bufsize, ssize_t *linksize)
return NULL;
}
+
+/* device_blocksize --- try to figure out units of st_blocks */
+
+static int
+device_blocksize()
+{
+ /* some of this derived from GNULIB stat-size.h */
+#if defined(DEV_BSIZE)
+ /* <sys/param.h>, most systems */
+ return DEV_BSIZE;
+#elif defined(S_BLKSIZE)
+ /* <sys/stat.h>, BSD systems */
+ return S_BLKSIZE;
+#elif defined hpux || defined __hpux__ || defined __hpux
+ return 1024;
+#elif defined _AIX && defined _I386
+ /* AIX PS/2 counts st_blocks in 4K units. */
+ return 4 * 1024;
+#elif defined __MINGW32__
+ return 1024;
+#else
+ return 512;
+#endif
+}
+
/* array_set --- set an array element */
static void
@@ -357,6 +385,9 @@ fill_stat_array(const char *name, awk_array_t array, struct stat *sbuf)
array_set_numeric(array, "blksize", 4096);
#endif /* HAVE_STRUCT_STAT_ST_BLKSIZE */
+ /* the size of a block for st_blocks */
+ array_set_numeric(array, "devbsize", device_blocksize());
+
pmode = format_mode(sbuf->st_mode);
array_set(array, "pmode", make_const_string(pmode, strlen(pmode), & tmp));