summaryrefslogtreecommitdiffhomepage
path: root/stc
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-01-21 08:26:54 +0100
committerTyge Løvset <[email protected]>2021-01-21 08:26:54 +0100
commit50da396d04714a18fa087ebbd1f2316958dbd6bd (patch)
tree0349909bf35183e2eced05ca0d3ce909f700c23e /stc
parent9473eae780011ef520066ddcd36bb555e8e616e4 (diff)
downloadSTC-modified-50da396d04714a18fa087ebbd1f2316958dbd6bd.tar.gz
STC-modified-50da396d04714a18fa087ebbd1f2316958dbd6bd.zip
Reverted namings: crand to crandom, and copt to coption.
Diffstat (limited to 'stc')
-rw-r--r--stc/clist.h2
-rw-r--r--stc/coption.h (renamed from stc/copt.h)30
-rw-r--r--stc/cpque.h2
-rw-r--r--stc/cqueue.h2
-rw-r--r--stc/crandom.h (renamed from stc/crand.h)6
5 files changed, 21 insertions, 21 deletions
diff --git a/stc/clist.h b/stc/clist.h
index 89bbc75c..1673d71e 100644
--- a/stc/clist.h
+++ b/stc/clist.h
@@ -31,7 +31,7 @@
#include <stdio.h>
#include <stc/clist.h>
- #include <stc/crand.h>
+ #include <stc/crandom.h>
using_clist(ix, int64_t);
int main() {
diff --git a/stc/copt.h b/stc/coption.h
index 5fc8fe4d..27ec880b 100644
--- a/stc/copt.h
+++ b/stc/coption.h
@@ -20,24 +20,24 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef COPT__H__
-#define COPT__H__
+#ifndef COPTION__H__
+#define COPTION__H__
/*
// Inspired by https://attractivechaos.wordpress.com/2018/08/31/a-survey-of-argument-parsing-libraries-in-c-c
// Fixed major bugs with option arguments (both long and short).
// Added arg->faulty output field, and has a more consistent API.
//
-// copt_get() is similar to GNU's getopt_long(). Each call parses one option and
+// coption_get() is similar to GNU's getopt_long(). Each call parses one option and
// returns the option name. opt->arg points to the option argument if present.
// The function returns -1 when all command-line arguments are parsed. In this case,
// opt->ind is the index of the first non-option argument.
#include <stdio.h>
-#include <stc/copt.h>
+#include <stc/coption.h>
int main(int argc, char *argv[])
{
- copt_long_t longopts[] = {
+ coption_long longopts[] = {
{"foo", copt_no_argument, 'f'},
{"bar", copt_required_argument, 'b'},
{"opt", copt_optional_argument, 'o'},
@@ -46,8 +46,8 @@ int main(int argc, char *argv[])
const char* optstr = "xy:z::123";
printf("program -x -y ARG -z [ARG] -1 -2 -3 --foo --bar ARG --opt [ARG] [ARGUMENTS]\n");
int c;
- copt_t opt = copt_init();
- while ((c = copt_get(&opt, argc, argv, optstr, longopts)) != -1) {
+ coption opt = coption_init();
+ while ((c = coption_get(&opt, argc, argv, optstr, longopts)) != -1) {
switch (c) {
case '?': printf("error: unknown option: %s\n", opt.faulty); break;
case ':': printf("error: missing argument for %s\n", opt.faulty); break;
@@ -77,16 +77,16 @@ typedef struct {
int longindex; /* idx of long option; or -1 if short */
int _i, _pos, _nargs;
char _faulty[4];
-} copt_t;
+} coption;
typedef struct {
const char *name;
int has_arg;
int val;
-} copt_long_t;
+} coption_long;
-static const copt_t copt_inits = {1, 0, NULL, NULL, -1, 1, 0, 0, {'-', '?', '\0'}};
-static inline copt_t copt_init(void) { return copt_inits; }
+static const coption coption_inits = {1, 0, NULL, NULL, -1, 1, 0, 0, {'-', '?', '\0'}};
+static inline coption coption_init(void) { return coption_inits; }
static void _copt_permute(char *argv[], int j, int n) { /* move argv[j] over n elements to the left */
int k;
@@ -96,13 +96,13 @@ static void _copt_permute(char *argv[], int j, int n) { /* move argv[j] over n e
argv[j - k] = p;
}
-/* @param opt output; must be initialized to copt_init() on first call
+/* @param opt output; must be initialized to coption_init() on first call
* @return ASCII val for a short option; longopt.val for a long option;
* -1 if argv[] is fully processed; '?' for an unknown option or
* an ambiguous long option; ':' if an option argument is missing
*/
-static int copt_get(copt_t *opt, int argc, char *argv[],
- const char *shortopts, const copt_long_t *longopts) {
+static int coption_get(coption *opt, int argc, char *argv[],
+ const char *shortopts, const coption_long *longopts) {
int optc = -1, i0, j, posixly_correct = (shortopts[0] == '+');
if (!posixly_correct) {
while (opt->_i < argc && (argv[opt->_i][0] != '-' || argv[opt->_i][1] == '\0'))
@@ -122,7 +122,7 @@ static int copt_get(copt_t *opt, int argc, char *argv[],
opt->opt = 0, optc = '?', opt->_pos = -1;
if (longopts) { /* parse long options */
int k, n_exact = 0, n_partial = 0;
- const copt_long_t *o = 0, *o_exact = 0, *o_partial = 0;
+ const coption_long *o = 0, *o_exact = 0, *o_partial = 0;
for (j = 2; argv[opt->_i][j] != '\0' && argv[opt->_i][j] != '='; ++j) {} /* find the end of the option name */
for (k = 0; longopts[k].name != 0; ++k)
if (strncmp(&argv[opt->_i][2], longopts[k].name, j - 2) == 0) {
diff --git a/stc/cpque.h b/stc/cpque.h
index 41113b7a..54ca04a7 100644
--- a/stc/cpque.h
+++ b/stc/cpque.h
@@ -23,7 +23,7 @@
/* Priority-Queue adapter (implemented as heap), default uses cvec.
- #include <stc/crand.h>
+ #include <stc/crandom.h>
#include <stc/cpque.h>
using_cvec(f, float);
using_cpque(f, cvec_f, >); // min-heap (increasing values)
diff --git a/stc/cqueue.h b/stc/cqueue.h
index fe202698..2c49b066 100644
--- a/stc/cqueue.h
+++ b/stc/cqueue.h
@@ -25,7 +25,7 @@
/* Queue adapter, default uses clist.
- #include <stc/crand.h>
+ #include <stc/crandom.h>
#include <stc/cqueue.h>
using_cdeq(i, int);
using_cqueue(i, cdeq_i);
diff --git a/stc/crand.h b/stc/crandom.h
index 727c61ac..c92a7de6 100644
--- a/stc/crand.h
+++ b/stc/crandom.h
@@ -24,8 +24,8 @@
#define CRANDOM__H__
/*
-// crand: Pseudo-random number generator
-#include "stc/crand.h"
+// crandom: Pseudo-random number generator
+#include "stc/crandom.h"
int main() {
uint64_t seed = 123456789;
stc64_t rng = stc64_init(seed);
@@ -112,7 +112,7 @@ STC_API double stc64_normalf(stc64_t* rng, stc64_normalf_t* dist);
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
-/* PRNG crand: by Tyge Løvset, NORCE Research, 2020.
+/* PRNG crandom: by Tyge Løvset, NORCE Research, 2020.
* Extremely fast PRNG suited for parallel usage with Weyl-sequence parameter.
* Faster than sfc64, wyhash64, and xoshiro256** on most platforms.
* 256bit state, updates only 192bit per rng.