Merge branch 'master' into add_input_test_file_option

This commit is contained in:
Alex Groce
2018-07-25 14:17:22 -07:00
2 changed files with 21 additions and 7 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ install:
- sudo apt-get -y install build-essential gcc-multilib cmake python python-pip python-setuptools libffi-dev
- sudo pip install -U pip ; sudo pip install manticore
- sudo pip uninstall -y Manticore || echo "Manticore not cached"
- sudo pip install https://github.com/trailofbits/manticore/archive/master.zip
- sudo pip install https://github.com/trailofbits/manticore/archive/last_python2.zip
- mkdir build
- cd build
- cmake ..
+20 -6
View File
@@ -21,6 +21,8 @@
#include <stdio.h>
#include <string.h>
DEFINE_bool(help, false, "Show the usage message.");
enum {
kMaxNumOptions = 32,
kMaxOptionLength = 1024 - 1
@@ -204,6 +206,11 @@ void DeepState_InitOptions(int argc, ...) {
ProcessOptionString();
DeepState_OptionsAreInitialized = 1;
ProcessPendingOptions();
if (FLAGS_help) {
DeepState_PrintAllOptions(argv[0]);
exit(0);
}
}
enum {
@@ -239,25 +246,32 @@ static const char *BufferDocString(char *buff, const char *docstring) {
/* Works for --help option: print out each options along with their document. */
void DeepState_PrintAllOptions(const char *prog_name) {
fprintf(stderr, "Usage: %s <options>\n\n", prog_name);
char buff[4096];
ssize_t write_len = 0;
char line_buff[kLineLength];
struct DeepState_Option *option = DeepState_Options;
struct DeepState_Option *next_option = NULL;
sprintf(buff, "Usage: %s <options>\n\n", prog_name);
write_len = write(STDERR_FILENO, buff, strlen(buff));
for (; option != NULL; option = next_option) {
next_option = option->next;
fprintf(stderr, "--%s", option->name);
sprintf(buff, "--%s", option->name);
write_len = write(STDERR_FILENO, buff, strlen(buff));
const char *docstring = option->docstring;
do {
docstring = BufferDocString(line_buff, docstring);
fprintf(stderr, "\n %s", line_buff);
sprintf(buff, "\n %s", line_buff);
write_len = write(STDERR_FILENO, buff, strlen(buff));
} while (*docstring);
fprintf(stderr, "\n\n");
write_len = write(STDERR_FILENO, "\n\n", 2);
}
(void) write_len; /* Deal with -Wunused-result. */
}
/* Initialize an option. */
void DeepState_AddOption(struct DeepState_Option *option) {
if (DeepState_OptionsAreInitialized) {