зеркало из https://github.com/mozilla/pjs.git
Escape newlines in keys. Explicitly mention empty arrays and hashes. Quote string values. Support undefined values.
This commit is contained in:
Родитель
649ce4b13d
Коммит
b7cc3989cc
|
@ -58,6 +58,7 @@ sub getDefaultString {
|
|||
key.replace('\\\\\\\\', '\\\\\\\\')
|
||||
.replace(' ', '\\\\ ')
|
||||
.replace('\\\\\\.', '\\\\.')
|
||||
.replace('\\n', '\\\\n')
|
||||
.replace('\\'', '\\\\\\'');
|
||||
'\\'';
|
||||
ELSE;
|
||||
|
@ -88,11 +89,16 @@ sub getDefaultString {
|
|||
SET key = frame.0;
|
||||
SET variable = frame.1;
|
||||
IF (variable.ref == 'HASH');
|
||||
IF (variable.keys.size);
|
||||
FOREACH subkey = variable.keys;
|
||||
SET name = key _ '.' _ debugDumpVarsEscape(subkey);
|
||||
debugDumpVarsStack.push([name, variable.\$subkey]);
|
||||
END;
|
||||
ELSE;
|
||||
debugDumpVarsVariables.\${key} = 'empty hash';
|
||||
END;
|
||||
ELSIF (variable.ref == 'ARRAY');
|
||||
IF (variable.size);
|
||||
SET index = variable.max;
|
||||
FOREACH item = variable;
|
||||
SET name = key _ '.' _ index;
|
||||
|
@ -100,12 +106,25 @@ sub getDefaultString {
|
|||
SET index = index + 1;
|
||||
END;
|
||||
ELSE;
|
||||
debugDumpVarsVariables.\${key} = 'empty array';
|
||||
END;
|
||||
ELSE;
|
||||
IF (!variable.defined);
|
||||
debugDumpVarsVariables.\${key} = 'undefined';
|
||||
ELSIF (variable.search('^[0-9]+(?:\\\\.[0+9]+)?\$'));
|
||||
debugDumpVarsVariables.\${key} = variable;
|
||||
ELSE;
|
||||
debugDumpVarsVariables.\${key} =
|
||||
'\\'' _
|
||||
variable.replace('\\\\\\\\', '\\\\\\\\')
|
||||
.replace('\\'', '\\\\\\'') _
|
||||
'\\'';
|
||||
END;
|
||||
END;
|
||||
IF key.length > debugDumpVarsMaxLength;
|
||||
debugDumpVarsMaxLength = key.length;
|
||||
END;
|
||||
END;
|
||||
END;
|
||||
|
||||
MACRO debugDumpVarsPad BLOCK;
|
||||
key | padright(debugDumpVarsMaxLength);
|
||||
|
|
Загрузка…
Ссылка в новой задаче