11/*
22 This file is part of cpp-ethereum.
3- cpp-ethereum is free software: you can redistribute it and/or modify
43
4+ cpp-ethereum is free software: you can redistribute it and/or modify
55 it under the terms of the GNU General Public License as published by
66 the Free Software Foundation, either version 3 of the License, or
77 (at your option) any later version.
@@ -81,6 +81,7 @@ to set locale to fail, so there are only two possible actions, the first is to
8181throw a runtime exception and cause the program to quit (default behaviour),
8282or the second is to modify the environment to something sensible (least
8383surprising behaviour).
84+
8485The follow code produces the least surprising behaviour. It will use the user
8586specified default locale if it is valid, and if not then it will modify the
8687environment the process is running in to use a sensible default. This also means
@@ -164,13 +165,8 @@ class RLPStreamer
164165 for (auto i: _d)
165166 {
166167 m_out << (j++ ?
167- <<<<<<< Updated upstream
168168 (m_prefs.indent .empty () ? " , " : (" ," + newline)) :
169169 (m_prefs.indent .empty () ? " " : newline));
170- =======
171- (m_prefs.indent .empty () ? " , " : (" ," + newline)) :
172- (m_prefs.indent .empty () ? " " : newline));
173- >>>>>>> Stashed changes
174170 output (i, _level + 1 );
175171 }
176172 newline = newline.substr (0 , newline.size () - m_prefs.indent .size ());
@@ -220,44 +216,7 @@ int main(int argc, char** argv)
220216 bool encrypt = false ;
221217 RLPStreamer::Prefs prefs;
222218
223- <<<<<<< Updated upstream
224219 for (int i = 1 ; i < argc; ++i)
225- =======
226- po::options_description renderOptions (" Render options" );
227- renderOptions.add_options ()
228- (" indent,i" , po::value<string> (), " <string> Use string as the level indentation (default ' ')." )
229- (" hex-ints" , " Render integers in hex." )
230- (" string-ints" , " Render integers in the same way as strings." )
231- (" ascii-strings" , " Render data as C-style strings or hex depending on content being ASCII." )
232- (" force-string" , " Force all data to be rendered as C-style strings." )
233- (" force-escape" , " When rendering as C-style strings, force all characters to be escaped." )
234- (" force-hex" , " Force all data to be rendered as raw hex." );
235-
236- po::options_description generalOptions (" General options" );
237- generalOptions.add_options ()
238- (" dapp,D" , " Dapp-building mode; equivalent to --encrypt --64." )
239- (" encrypt,e" , " Encrypt the RLP data prior to output." )
240- (" lenience,L" , " Try not to bomb out early if possible." )
241- (" hex,x" , " Treat input RLP as hex encoded data." )
242- (" base-16" , " Treat input RLP as hex encoded data." )
243- (" keccak,k" , " Output Keccak-256 hash only." )
244- (" base-64" , " Treat input RLP as base-64 encoded data." )
245- (" 64" , " Treat input RLP as base-64 encoded data." )
246- (" bin,b" , " Treat input RLP as raw binary data." )
247- (" base-256" , " Treat input RLP as raw binary data." )
248- (" quiet,q" , " Don't place additional information on stderr." )
249- (" help,h" , " Print this help message and exit." )
250- (" version,V" , " Show the version and exit." );
251-
252- po::options_description allowedOptions (" Allowed options" );
253- allowedOptions.add (generalOptions).add (renderOptions);
254- po::parsed_options parsed = po::command_line_parser (argc, argv).options (allowedOptions).allow_unregistered ().run ();
255- vector<string> unrecognisedOptions = collect_unrecognized (parsed.options , po::include_positional);
256- po::variables_map vm;
257- po::store (parsed, vm);
258- po::notify (vm);
259- for (size_t i = 0 ; i < unrecognisedOptions.size (); ++i)
260- >>>>>>> Stashed changes
261220 {
262221 string arg = argv[i];
263222 if (arg == " -h" || arg == " --help" )
@@ -311,53 +270,6 @@ int main(int argc, char** argv)
311270 else
312271 otherInputs.push_back (arg);
313272 }
314- <<<<<<< Updated upstream
315- =======
316- if (vm.count (" help" )) {
317- cout << " Usage rlp <mode> [OPTIONS]\n Modes:\n "
318- << " create <json> Given a simplified JSON string, output the RLP." << endl
319- << " render [ <file> | -- ] Render the given RLP. Options:" << endl
320- << " list [ <file> | -- ] List the items in the RLP list by hash and size." << endl
321- << " extract [ <file> | -- ] Extract all items in the RLP list, named by hash." << endl
322- << " assemble [ <manifest> | <base path> ] <file> ... Given a manifest & files, output the RLP." << endl
323- << renderOptions << generalOptions;
324- exit (0 );
325- }
326- if (vm.count (" lenience" ))
327- lenience = true ;
328- if (vm.count (" dapp" ))
329- encrypt = true , encoding = Encoding::Base64;
330- if (vm.count (" version" ))
331- version ();
332- if (vm.count (" quiet" ))
333- quiet = true ;
334- if (vm.count (" hex" ) || vm.count (" base-16" ))
335- encoding = Encoding::Hex;
336- if (vm.count (" keccak" ))
337- encoding = Encoding::Keccak;
338- if (vm.count (" 64" ) || vm.count (" base-64" ))
339- encoding = Encoding::Base64;
340- if (vm.count (" bin" ) || vm.count (" base-256" ))
341- encoding = Encoding::Binary;
342- if (vm.count (" encrypt" ))
343- encrypt = true ;
344- if (vm.count (" indent" ))
345- prefs.indent = vm[" indent" ].as <string>();
346- if (vm.count (" hex-ints" ))
347- prefs.hexInts = true ;
348- if (vm.count (" string-ints" ))
349- prefs.stringInts = true ;
350- if (vm.count (" ascii-strings" ))
351- prefs.forceString = prefs.forceHex = false ;
352- if (vm.count (" force-string" ))
353- prefs.forceString = true ;
354- if (vm.count (" force-hex" ))
355- prefs.forceHex = true , prefs.forceString = false ;
356- if (vm.count (" force-escape" ))
357- prefs.escapeAll = true ;
358- if (vm.count (" nice" ))
359- prefs.forceString = true , prefs.stringInts = false , prefs.forceHex = false , prefs.indent = " " ;
360- >>>>>>> Stashed changes
361273
362274 bytes in;
363275 if (inputFile == " --" )
@@ -590,4 +502,4 @@ int main(int argc, char** argv)
590502 }
591503
592504 return 0 ;
593- }
505+ }
0 commit comments