Skip to content

Commit

Permalink
rename PI and E to M_PI and M_E
Browse files Browse the repository at this point in the history
  • Loading branch information
johnkerl committed Dec 19, 2017
1 parent cb7f966 commit ddff0b7
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 90 deletions.
2 changes: 2 additions & 0 deletions c/draft-release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ for those times when you want integer overflow.
an alias for `--nidx --fs tab`, and `mlr -t` is an alias for `mlr
--tsvlite`.

* The mathematical constants pi and e have been renamed from `PI` and `E` to `M_PI` and `M_E`, respectively. (It's annoying to get a syntax error when you try to define a variable named `E` in the DSL, when `A` through `D` work just fine.) This is a backward incompatibility, but not enough of us to justify calling this release Miller 6.0.0.

## Documentation:

* As noted
Expand Down
2 changes: 1 addition & 1 deletion c/dsl/function_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ void fmgr_function_usage(fmgr_t* pfmgr, FILE* output_stream, char* function_name
fprintf(output_stream, "numbers of the form \"%s --seed 123456789\" or \"%s --seed 0xcafefeed\".\n",
MLR_GLOBALS.bargv0, MLR_GLOBALS.bargv0);
fprintf(output_stream, "Miller's built-in variables are NF, NR, FNR, FILENUM, and FILENAME (awk-like)\n");
fprintf(output_stream, "along with the mathematical constants PI and E.\n");
fprintf(output_stream, "along with the mathematical constants M_PI and M_E.\n");
}
}

Expand Down
56 changes: 28 additions & 28 deletions c/dsl/mlr_dsl_cst_keywords.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@
// ----------------------------------------------------------------
typedef void keyword_usage_func_t(FILE* ostream);

static keyword_usage_func_t mlr_dsl_ENV_keyword_usage;
static keyword_usage_func_t mlr_dsl_FILENAME_keyword_usage;
static keyword_usage_func_t mlr_dsl_FILENUM_keyword_usage;
static keyword_usage_func_t mlr_dsl_FNR_keyword_usage;
static keyword_usage_func_t mlr_dsl_IFS_keyword_usage;
static keyword_usage_func_t mlr_dsl_IPS_keyword_usage;
static keyword_usage_func_t mlr_dsl_IRS_keyword_usage;
static keyword_usage_func_t mlr_dsl_M_E_keyword_usage;
static keyword_usage_func_t mlr_dsl_M_PI_keyword_usage;
static keyword_usage_func_t mlr_dsl_NF_keyword_usage;
static keyword_usage_func_t mlr_dsl_NR_keyword_usage;
static keyword_usage_func_t mlr_dsl_OFS_keyword_usage;
static keyword_usage_func_t mlr_dsl_OPS_keyword_usage;
static keyword_usage_func_t mlr_dsl_ORS_keyword_usage;
static keyword_usage_func_t mlr_dsl_all_keyword_usage;
static keyword_usage_func_t mlr_dsl_begin_keyword_usage;
static keyword_usage_func_t mlr_dsl_bool_keyword_usage;
Expand Down Expand Up @@ -46,20 +60,6 @@ static keyword_usage_func_t mlr_dsl_true_keyword_usage;
static keyword_usage_func_t mlr_dsl_unset_keyword_usage;
static keyword_usage_func_t mlr_dsl_var_keyword_usage;
static keyword_usage_func_t mlr_dsl_while_keyword_usage;
static keyword_usage_func_t mlr_dsl_E_keyword_usage;
static keyword_usage_func_t mlr_dsl_ENV_keyword_usage;
static keyword_usage_func_t mlr_dsl_FILENAME_keyword_usage;
static keyword_usage_func_t mlr_dsl_FILENUM_keyword_usage;
static keyword_usage_func_t mlr_dsl_FNR_keyword_usage;
static keyword_usage_func_t mlr_dsl_IFS_keyword_usage;
static keyword_usage_func_t mlr_dsl_IPS_keyword_usage;
static keyword_usage_func_t mlr_dsl_IRS_keyword_usage;
static keyword_usage_func_t mlr_dsl_NF_keyword_usage;
static keyword_usage_func_t mlr_dsl_NR_keyword_usage;
static keyword_usage_func_t mlr_dsl_OFS_keyword_usage;
static keyword_usage_func_t mlr_dsl_OPS_keyword_usage;
static keyword_usage_func_t mlr_dsl_ORS_keyword_usage;
static keyword_usage_func_t mlr_dsl_PI_keyword_usage;

// ----------------------------------------------------------------
typedef struct _keyword_usage_entry_t {
Expand Down Expand Up @@ -108,20 +108,20 @@ static keyword_usage_entry_t KEYWORD_USAGE_TABLE[] = {
{ "unset", mlr_dsl_unset_keyword_usage },
{ "var", mlr_dsl_var_keyword_usage },
{ "while", mlr_dsl_while_keyword_usage },
{ "E", mlr_dsl_E_keyword_usage },
{ "ENV", mlr_dsl_ENV_keyword_usage },
{ "FILENAME", mlr_dsl_FILENAME_keyword_usage },
{ "FILENUM", mlr_dsl_FILENUM_keyword_usage },
{ "FNR", mlr_dsl_FNR_keyword_usage },
{ "IFS", mlr_dsl_IFS_keyword_usage },
{ "IPS", mlr_dsl_IPS_keyword_usage },
{ "IRS", mlr_dsl_IRS_keyword_usage },
{ "M_E", mlr_dsl_M_E_keyword_usage },
{ "M_PI", mlr_dsl_M_PI_keyword_usage },
{ "NF", mlr_dsl_NF_keyword_usage },
{ "NR", mlr_dsl_NR_keyword_usage },
{ "OFS", mlr_dsl_OFS_keyword_usage },
{ "OPS", mlr_dsl_OPS_keyword_usage },
{ "ORS", mlr_dsl_ORS_keyword_usage },
{ "PI", mlr_dsl_PI_keyword_usage },

};
static int KEYWORD_USAGE_TABLE_SIZE = sizeof(KEYWORD_USAGE_TABLE)/sizeof(KEYWORD_USAGE_TABLE[0]);
Expand Down Expand Up @@ -562,12 +562,6 @@ static void mlr_dsl_while_keyword_usage(FILE* ostream) {
);
}

static void mlr_dsl_E_keyword_usage(FILE *ostream) {
fprintf(ostream,
"E: the mathematical constant.\n"
);
}

static void mlr_dsl_ENV_keyword_usage(FILE *ostream) {
fprintf(ostream,
"ENV: access to environment variables by name, e.g. '$home = ENV[\"HOME\"]'\n"
Expand Down Expand Up @@ -614,6 +608,18 @@ static void mlr_dsl_IRS_keyword_usage(FILE *ostream) {
);
}

static void mlr_dsl_M_E_keyword_usage(FILE *ostream) {
fprintf(ostream,
"M_E: the mathematical constant e.\n"
);
}

static void mlr_dsl_M_PI_keyword_usage(FILE *ostream) {
fprintf(ostream,
"M_PI: the mathematical constant pi.\n"
);
}

static void mlr_dsl_NF_keyword_usage(FILE *ostream) {
fprintf(ostream,
"NF: evaluates to the number of fields in the current record.\n"
Expand Down Expand Up @@ -647,9 +653,3 @@ static void mlr_dsl_ORS_keyword_usage(FILE *ostream) {
);
}

static void mlr_dsl_PI_keyword_usage(FILE *ostream) {
fprintf(ostream,
"PI: the mathematical constant.\n"
);
}

8 changes: 4 additions & 4 deletions c/dsl/rval_expr_evaluators.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ mv_t rval_evaluator_PI_func(void* pvstate, variables_t* pvars) {
static void rval_evaluator_PI_free(rval_evaluator_t* pevaluator) {
free(pevaluator);
}
rval_evaluator_t* rval_evaluator_alloc_from_PI() {
rval_evaluator_t* rval_evaluator_alloc_from_M_PI() {
rval_evaluator_t* pevaluator = mlr_malloc_or_die(sizeof(rval_evaluator_t));
pevaluator->pvstate = NULL;
pevaluator->pprocess_func = rval_evaluator_PI_func;
Expand All @@ -786,7 +786,7 @@ mv_t rval_evaluator_E_func(void* pvstate, variables_t* pvars) {
static void rval_evaluator_E_free(rval_evaluator_t* pevaluator) {
free(pevaluator);
}
rval_evaluator_t* rval_evaluator_alloc_from_E() {
rval_evaluator_t* rval_evaluator_alloc_from_M_E() {
rval_evaluator_t* pevaluator = mlr_malloc_or_die(sizeof(rval_evaluator_t));
pevaluator->pvstate = NULL;
pevaluator->pprocess_func = rval_evaluator_E_func;
Expand Down Expand Up @@ -901,8 +901,8 @@ rval_evaluator_t* rval_evaluator_alloc_from_context_variable(char* variable_name
} else if (streq(variable_name, "FNR")) { return rval_evaluator_alloc_from_FNR();
} else if (streq(variable_name, "FILENAME")) { return rval_evaluator_alloc_from_FILENAME();
} else if (streq(variable_name, "FILENUM")) { return rval_evaluator_alloc_from_FILENUM();
} else if (streq(variable_name, "PI")) { return rval_evaluator_alloc_from_PI();
} else if (streq(variable_name, "E")) { return rval_evaluator_alloc_from_E();
} else if (streq(variable_name, "M_PI")) { return rval_evaluator_alloc_from_M_PI();
} else if (streq(variable_name, "M_E")) { return rval_evaluator_alloc_from_M_E();
} else if (streq(variable_name, "IPS")) { return rval_evaluator_alloc_from_IPS();
} else if (streq(variable_name, "IFS")) { return rval_evaluator_alloc_from_IFS();
} else if (streq(variable_name, "IRS")) { return rval_evaluator_alloc_from_IRS();
Expand Down
2 changes: 1 addition & 1 deletion c/mapping/mapper_put_or_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static void shared_usage(FILE* o, char* argv0, char* verb) {
fprintf(o, "Please use a dollar sign for field names and double-quotes for string\n");
fprintf(o, "literals. If field names have special characters such as \".\" then you might\n");
fprintf(o, "use braces, e.g. '${field.name}'. Miller built-in variables are\n");
fprintf(o, "NF NR FNR FILENUM FILENAME PI E, and ENV[\"namegoeshere\"] to access environment\n");
fprintf(o, "NF NR FNR FILENUM FILENAME M_PI M_E, and ENV[\"namegoeshere\"] to access environment\n");
fprintf(o, "variables. The environment-variable name may be an expression, e.g. a field\n");
fprintf(o, "value.\n");
fprintf(o, "\n");
Expand Down
4 changes: 2 additions & 2 deletions c/parsing/ex1_lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,11 @@ false {
*yyextra = ex_ast_node_alloc(yytext, MD_AST_NODE_TYPE_CONTEXT_VARIABLE);
return MD_TOKEN_CONTEXT_VARIABLE;
}
"PI" {
"M_PI" {
*yyextra = ex_ast_node_alloc(yytext, MD_AST_NODE_TYPE_CONTEXT_VARIABLE);
return MD_TOKEN_CONTEXT_VARIABLE;
}
"E" {
"M_E" {
*yyextra = ex_ast_node_alloc(yytext, MD_AST_NODE_TYPE_CONTEXT_VARIABLE);
return MD_TOKEN_CONTEXT_VARIABLE;
}
Expand Down
4 changes: 2 additions & 2 deletions c/parsing/mlr_dsl_lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,11 @@
*yyextra = mlr_dsl_ast_node_alloc(yytext, MD_AST_NODE_TYPE_CONTEXT_VARIABLE);
return MD_TOKEN_CONTEXT_VARIABLE;
}
"PI" {
"M_PI" {
*yyextra = mlr_dsl_ast_node_alloc(yytext, MD_AST_NODE_TYPE_CONTEXT_VARIABLE);
return MD_TOKEN_CONTEXT_VARIABLE;
}
"E" {
"M_E" {
*yyextra = mlr_dsl_ast_node_alloc(yytext, MD_AST_NODE_TYPE_CONTEXT_VARIABLE);
return MD_TOKEN_CONTEXT_VARIABLE;
}
Expand Down
6 changes: 3 additions & 3 deletions doc/content-for-reference-dsl.html
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ <h1>Variables</h1>
<p/>Miller has the following kinds of variables:

<p/> <b>Built-in variables</b> such as <tt>NF</tt>, <tt>NF</tt>,
<tt>FILENAME</tt>, <tt>PI</tt>, and <tt>E</tt>. These are all capital letters
<tt>FILENAME</tt>, <tt>M_PI</tt>, and <tt>M_E</tt>. These are all capital letters
and are read-only (although some of them change value from one record to
another).

Expand Down Expand Up @@ -209,8 +209,8 @@ <h2>Built-in variables</h2>
<p/>Namely, Miller supports the following five built-in variables for <a
href="reference-verbs.html#filter"><tt>filter</tt></a> and <tt>put</tt>, all <tt>awk</tt>-inspired:
<tt>NF</tt>, <tt>NR</tt>, <tt>FNR</tt>, <tt>FILENUM</tt>, and
<tt>FILENAME</tt>, as well as the mathematical constants <tt>PI</tt> and
<tt>E</tt>. Lastly, the <tt>ENV</tt> hashmap allows read access to environment
<tt>FILENAME</tt>, as well as the mathematical constants <tt>M_PI</tt> and
<tt>M_E</tt>. Lastly, the <tt>ENV</tt> hashmap allows read access to environment
variables, e.g. <tt>ENV["HOME"]</tt> or <tt>ENV["foo_".$hostname]</tt>.

POKI_RUN_COMMAND{{mlr filter 'FNR == 2' data/small*}}HERE
Expand Down
18 changes: 9 additions & 9 deletions doc/manpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@
Please use a dollar sign for field names and double-quotes for string
literals. If field names have special characters such as "." then you might
use braces, e.g. '${field.name}'. Miller built-in variables are
NF NR FNR FILENUM FILENAME PI E, and ENV["namegoeshere"] to access environment
NF NR FNR FILENUM FILENAME M_PI M_E, and ENV["namegoeshere"] to access environment
variables. The environment-variable name may be an expression, e.g. a field
value.

Expand Down Expand Up @@ -1013,7 +1013,7 @@
Please use a dollar sign for field names and double-quotes for string
literals. If field names have special characters such as "." then you might
use braces, e.g. '${field.name}'. Miller built-in variables are
NF NR FNR FILENUM FILENAME PI E, and ENV["namegoeshere"] to access environment
NF NR FNR FILENUM FILENAME M_PI M_E, and ENV["namegoeshere"] to access environment
variables. The environment-variable name may be an expression, e.g. a field
value.

Expand Down Expand Up @@ -2232,9 +2232,6 @@
while: introduces a while loop, or with "do", introduces a do-while loop.
The body statements must be wrapped in curly braces.

E
E: the mathematical constant.

ENV
ENV: access to environment variables by name, e.g. '$home = ENV["HOME"]'

Expand All @@ -2260,6 +2257,12 @@
or to LF or CRLF from the input data if in autodetect mode (which is
the default).

M_E
M_E: the mathematical constant e.

M_PI
M_PI: the mathematical constant pi.

NF
NF: evaluates to the number of fields in the current record.

Expand All @@ -2278,9 +2281,6 @@
or to LF or CRLF from the input data if in autodetect mode (which is
the default).

PI
PI: the mathematical constant.

AUTHOR
Miller is written by John Kerl &lt;kerl.john.r@gmail.com&gt;.

Expand All @@ -2294,7 +2294,7 @@



2017-11-18 MILLER(1)
2017-12-19 MILLER(1)
</pre>
</div>
<p/>
Expand Down
18 changes: 9 additions & 9 deletions doc/manpage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ VERBS
Please use a dollar sign for field names and double-quotes for string
literals. If field names have special characters such as "." then you might
use braces, e.g. '${field.name}'. Miller built-in variables are
NF NR FNR FILENUM FILENAME PI E, and ENV["namegoeshere"] to access environment
NF NR FNR FILENUM FILENAME M_PI M_E, and ENV["namegoeshere"] to access environment
variables. The environment-variable name may be an expression, e.g. a field
value.

Expand Down Expand Up @@ -819,7 +819,7 @@ VERBS
Please use a dollar sign for field names and double-quotes for string
literals. If field names have special characters such as "." then you might
use braces, e.g. '${field.name}'. Miller built-in variables are
NF NR FNR FILENUM FILENAME PI E, and ENV["namegoeshere"] to access environment
NF NR FNR FILENUM FILENAME M_PI M_E, and ENV["namegoeshere"] to access environment
variables. The environment-variable name may be an expression, e.g. a field
value.

Expand Down Expand Up @@ -2038,9 +2038,6 @@ KEYWORDS FOR PUT AND FILTER
while: introduces a while loop, or with "do", introduces a do-while loop.
The body statements must be wrapped in curly braces.

E
E: the mathematical constant.

ENV
ENV: access to environment variables by name, e.g. '$home = ENV["HOME"]'

Expand All @@ -2066,6 +2063,12 @@ KEYWORDS FOR PUT AND FILTER
or to LF or CRLF from the input data if in autodetect mode (which is
the default).

M_E
M_E: the mathematical constant e.

M_PI
M_PI: the mathematical constant pi.

NF
NF: evaluates to the number of fields in the current record.

Expand All @@ -2084,9 +2087,6 @@ KEYWORDS FOR PUT AND FILTER
or to LF or CRLF from the input data if in autodetect mode (which is
the default).

PI
PI: the mathematical constant.

AUTHOR
Miller is written by John Kerl <kerl.john.r@gmail.com>.

Expand All @@ -2100,4 +2100,4 @@ SEE ALSO



2017-11-18 MILLER(1)
2017-12-19 MILLER(1)
Loading

0 comments on commit ddff0b7

Please sign in to comment.