This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".
The branch, master has been updated
via b89083b52e8354b11f1d4da207e083702c78cf10 (commit)
from 33d0f635771f7418c356bf821888cfcfa6d588f9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://scm.fusionforge.org/anonscm/gitweb/?p=fusionforge/fusionforge.git;a=commitdiff;h=b89083b52e8354b11f1d4da207e083702c78cf10
commit b89083b52e8354b11f1d4da207e083702c78cf10
Author: mirabilos <[email protected]>
Date: Fri Apr 14 22:04:47 2017 +0200
update from master copy
diff --git a/src/common/include/minijson.php b/src/common/include/minijson.php
index b927c94..6b96cbc 100644
--- a/src/common/include/minijson.php
+++ b/src/common/include/minijson.php
@@ -1,4 +1,5 @@
<?php
+if (count(get_included_files()) === 1) define('__main__', __FILE__);
/**
* Minimal complete JSON generator and parser for FusionForge and SimKolab
*
@@ -23,6 +24,11 @@
* Do *not* use PHP’s json_encode because it is broken.
* Note that JSON is case-sensitive. My notes are at:
* https://www.mirbsd.org/cvs.cgi/contrib/hosted/tg/json.txt?rev=HEAD
+ *
+ * Call as CLI script to filter input as JSON pretty-printer. Options
+ * are -c (compact output, no indentation or spaces), -d depth (parse
+ * depth defaulting to 32), -r (pretty-print resources as string) and
+ * -t truncsz (truncation size).
*/
/*-
@@ -705,3 +711,80 @@ function minijson_decode_number(&$j, &$p, &$ov) {
$ov = (float)$s;
return true;
}
+
+if (defined('__main__') && constant('__main__') === __FILE__) {
+ function usage($rc=1) {
+ fwrite(STDERR,
+ "Syntax: minijson.php [-cr] [-d depth] [-t truncsz]\n");
+ exit($rc);
+ }
+
+ $indent = '';
+ $depth = 32;
+ $truncsz = 0;
+ $rsrc = false;
+ array_shift($argv); /* argv[0] */
+ while (count($argv)) {
+ $arg = array_shift($argv);
+ /* only options, no arguments (Unix filter) */
+ if ($arg[0] !== '-')
+ usage();
+ if ($arg === '--' && count($argv))
+ usage();
+ if ($arg === '-')
+ usage();
+ $arg = str_split($arg);
+ array_shift($arg); /* initial ‘-’ */
+ /* parse select arguments */
+ while (count($arg)) {
+ switch ($arg[0]) {
+ case 'c':
+ $indent = false;
+ break;
+ case 'd':
+ if (!count($argv))
+ usage();
+ $depth = array_shift($argv);
+ if (!preg_match('/^[1-9][0-9]*$/', $depth))
+ usage();
+ if ((string)(int)$depth !== $depth)
+ usage();
+ $depth = (int)$depth;
+ break;
+ case 'h':
+ case '?':
+ usage(0);
+ case 'r':
+ $rsrc = true;
+ break;
+ case 't':
+ if (!count($argv))
+ usage();
+ $truncsz = array_shift($argv);
+ if (!preg_match('/^[1-9][0-9]*$/', $truncsz))
+ usage();
+ if ((string)(int)$truncsz !== $truncsz)
+ usage();
+ $truncsz = (int)$truncsz;
+ break;
+ default:
+ usage();
+ }
+ array_shift($arg);
+ }
+ }
+
+ $idat = file_get_contents('php://stdin');
+ $odat = '';
+ if (!minijson_decode($idat, $odat, $depth)) {
+ fwrite(STDERR, 'JSON decoding of input failed: ' .
+ minijson_encode(array(
+ 'input' => $idat,
+ 'message' => $odat,
+ )) . "\n");
+ exit(1);
+ }
+ fwrite(STDOUT, minijson_encode_internal($odat, $indent, $depth,
+ $truncsz, $rsrc) . "\n");
+ exit(0);
+}
-----------------------------------------------------------------------
Summary of changes:
src/common/include/minijson.php | 83 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+)
hooks/post-receive
--
FusionForge
_______________________________________________
Fusionforge-commits mailing list
[email protected]
http://lists.fusionforge.org/cgi-bin/mailman/listinfo/fusionforge-commits