| 1 |
/* Integration test to verify that we don't explode in this |
| 2 |
argument-parsing logic. |
| 3 |
Adapted from part of bzip2-1.0.8: bzip2.c: main. */ |
| 4 |
|
| 5 |
#include <stdlib.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include "analyzer-decls.h" |
| 8 |
|
| 9 |
/* This test file has been heavily modified from the bzip2.c original, |
| 10 |
which has the following license boilerplate. */ |
| 11 |
/* ------------------------------------------------------------------ |
| 12 |
This file is part of bzip2/libbzip2, a program and library for |
| 13 |
lossless, block-sorting data compression. |
| 14 |
|
| 15 |
bzip2/libbzip2 version 1.0.8 of 13 July 2019 |
| 16 |
Copyright (C) 1996-2019 Julian Seward <[email protected]> |
| 17 |
|
| 18 |
Please read the WARNING, DISCLAIMER and PATENTS sections in the |
| 19 |
README file. |
| 20 |
|
| 21 |
This program is released under the terms of the license contained |
| 22 |
in the file LICENSE. |
| 23 |
------------------------------------------------------------------ */ |
| 24 |
|
| 25 |
typedef char Char; |
| 26 |
typedef unsigned char Bool; |
| 27 |
typedef int Int32; |
| 28 |
|
| 29 |
#define True ((Bool)1) |
| 30 |
#define False ((Bool)0) |
| 31 |
|
| 32 |
typedef |
| 33 |
struct zzzz { |
| 34 |
Char *name; |
| 35 |
struct zzzz *link; |
| 36 |
} |
| 37 |
Cell; |
| 38 |
|
| 39 |
Int32 verbosity; |
| 40 |
Bool keepInputFiles, smallMode; |
| 41 |
Bool forceOverwrite, noisy; |
| 42 |
Int32 blockSize100k; |
| 43 |
Int32 opMode; |
| 44 |
Int32 srcMode; |
| 45 |
Char *progName; |
| 46 |
|
| 47 |
extern void license ( void ); |
| 48 |
extern void usage ( Char *fullProgName ); |
| 49 |
|
| 50 |
void test (Cell *argList) |
| 51 |
{ |
| 52 |
Cell *aa; |
| 53 |
Int32 i, j; |
| 54 |
|
| 55 |
for (aa = argList; aa != NULL; aa = aa->link) { |
| 56 |
if (aa->name[0] == '-' && aa->name[1] != '-') { |
| 57 |
for (j = 1; aa->name[j] != '\0'; j++) { |
| 58 |
switch (aa->name[j]) { |
| 59 |
case 'c': srcMode = 2; break; |
| 60 |
case 'd': opMode = 2; break; |
| 61 |
case 'z': opMode = 1; break; |
| 62 |
case 'f': forceOverwrite = True; break; |
| 63 |
case 't': opMode = 3; break; |
| 64 |
case 'k': keepInputFiles = True; break; |
| 65 |
case 's': smallMode = True; break; |
| 66 |
case 'q': noisy = False; break; |
| 67 |
case '1': blockSize100k = 1; break; |
| 68 |
case '2': blockSize100k = 2; break; |
| 69 |
case '3': blockSize100k = 3; break; |
| 70 |
case '4': blockSize100k = 4; break; |
| 71 |
case '5': blockSize100k = 5; break; |
| 72 |
case '6': blockSize100k = 6; break; |
| 73 |
case '7': blockSize100k = 7; break; |
| 74 |
case '8': blockSize100k = 8; break; |
| 75 |
case '9': blockSize100k = 9; break; |
| 76 |
case 'V': |
| 77 |
case 'L': license(); break; |
| 78 |
case 'v': verbosity++; break; |
| 79 |
case 'h': usage ( progName ); |
| 80 |
exit ( 0 ); |
| 81 |
break; |
| 82 |
default: fprintf ( stderr, "%s: Bad flag `%s'\n", |
| 83 |
progName, aa->name ); |
| 84 |
usage ( progName ); |
| 85 |
exit ( 1 ); |
| 86 |
break; |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
/* The analyzer ought to be able to successfully merge all of the |
| 93 |
above changes that can reach here into a single state. */ |
| 94 |
__analyzer_dump_exploded_nodes (0); /* { dg-warning "1 processed enode" } */ |
| 95 |
} |