diff options
author | Emmanuel Mogenet <emogenet@gmail.com> | 2017-04-16 22:05:07 +0200 |
---|---|---|
committer | Emmanuel Mogenet <emogenet@gmail.com> | 2017-04-16 22:05:07 +0200 |
commit | ba52acf5442bfdc69bd8ef3f8aee88b6af4a73c5 (patch) | |
tree | bccfe8cb64e5ea6e9c29f94e9cca8072eec8b66b /src/grt | |
parent | 5e2df60d66d601f327d9c31e1880806aee6eb2e4 (diff) | |
download | ghdl-ba52acf5442bfdc69bd8ef3f8aee88b6af4a73c5.tar.gz ghdl-ba52acf5442bfdc69bd8ef3f8aee88b6af4a73c5.tar.bz2 ghdl-ba52acf5442bfdc69bd8ef3f8aee88b6af4a73c5.zip |
Feed new code through indent to match indigenous style
Diffstat (limited to 'src/grt')
-rw-r--r-- | src/grt/ghwdump.c | 145 | ||||
-rw-r--r-- | src/grt/ghwlib.c | 95 |
2 files changed, 119 insertions, 121 deletions
diff --git a/src/grt/ghwdump.c b/src/grt/ghwdump.c index 9bea0a17f..3b898d33d 100644 --- a/src/grt/ghwdump.c +++ b/src/grt/ghwdump.c @@ -41,92 +41,87 @@ usage (void) " -v verbose\n"); } -static void add_single_signal( - int **signalSet, - int *nbSignals, - int signal -) { - assert(NULL!=signalSet); - assert(NULL!=nbSignals); - assert(0<=nbSignals[0]); - assert(0<=signal); +static void +add_single_signal (int **signalSet, int *nbSignals, int signal) +{ + assert (NULL != signalSet); + assert (NULL != nbSignals); + assert (0 <= nbSignals[0]); + assert (0 <= signal); - int newSize = (1 + nbSignals[0]); - /*printf("adding signal %6d set of signals to display\n", signal);*/ - signalSet[0] = (int*)realloc(signalSet[0], newSize*sizeof(int)); - signalSet[0][nbSignals[0]] = signal; - nbSignals[0] = newSize; + int newSize = (1 + nbSignals[0]); + /*printf("adding signal %6d set of signals to display\n", signal); */ + signalSet[0] = (int *) realloc (signalSet[0], newSize * sizeof (int)); + signalSet[0][nbSignals[0]] = signal; + nbSignals[0] = newSize; } -static void add_signal_range( - int **signalSet, - int *nbSignals, - const char *s, - const char *e -) { +static void +add_signal_range (int **signalSet, + int *nbSignals, const char *s, const char *e) +{ - int i; - int rangeSize; - int rangeEnd = -1; - int rangeStart = -1; - int bytesMatched = -1; - int expected = ((e - s) - 1); - int itemsMatched =sscanf( - s, - "%d-%d%n", - &rangeStart, - &rangeEnd, - &bytesMatched - ); - if(2==itemsMatched && expected==bytesMatched) { - if(rangeEnd<rangeStart) { - int t = rangeEnd; - rangeEnd = rangeStart; - rangeStart = t; - } - } else { - itemsMatched = sscanf( - s, - "%d%n", - &rangeStart, - &bytesMatched - ); - if(1==itemsMatched && expected==bytesMatched) { - if(0<=rangeStart) { - rangeEnd = rangeStart; - } - } + int i; + int rangeSize; + int rangeEnd = -1; + int rangeStart = -1; + int bytesMatched = -1; + int expected = ((e - s) - 1); + int itemsMatched = sscanf (s, + "%d-%d%n", + &rangeStart, + &rangeEnd, + &bytesMatched); + if (2 == itemsMatched && expected == bytesMatched) + { + if (rangeEnd < rangeStart) + { + int t = rangeEnd; + rangeEnd = rangeStart; + rangeStart = t; + } + } + else + { + itemsMatched = sscanf (s, "%d%n", &rangeStart, &bytesMatched); + if (1 == itemsMatched && expected == bytesMatched) + { + if (0 <= rangeStart) + { + rangeEnd = rangeStart; + } + } } - rangeSize = (rangeEnd - rangeStart); - if(rangeEnd<0 || rangeStart<0 || rangeSize<0) { - fprintf( - stderr, - "incorrect signal range specification\"%s\" found in command line, aborting\n", - s - ); - exit(1); + rangeSize = (rangeEnd - rangeStart); + if (rangeEnd < 0 || rangeStart < 0 || rangeSize < 0) + { + fprintf (stderr, + "incorrect signal range specification\"%s\" found in command line, aborting\n", + s); + exit (1); } - for(i=rangeStart; i<=rangeEnd; ++i) { - add_single_signal(signalSet, nbSignals, i); + for (i = rangeStart; i <= rangeEnd; ++i) + { + add_single_signal (signalSet, nbSignals, i); } } -static void add_signals( - int **signalSet, - int *nbSignals, - const char *arg -) { - int c = -1; - const char *e; - const char *s = e = arg; - while(0!=c) { - c = *(e++); - if(','==c || 0==c) { - add_signal_range(signalSet, nbSignals, s, e); - s = e; - } +static void +add_signals (int **signalSet, int *nbSignals, const char *arg) +{ + int c = -1; + const char *e; + const char *s = e = arg; + while (0 != c) + { + c = *(e++); + if (',' == c || 0 == c) + { + add_signal_range (signalSet, nbSignals, s, e); + s = e; + } } } diff --git a/src/grt/ghwlib.c b/src/grt/ghwlib.c index c16936b1e..bee84687c 100644 --- a/src/grt/ghwlib.c +++ b/src/grt/ghwlib.c @@ -1346,60 +1346,63 @@ ghw_get_value (char *buf, int len, union ghw_val *val, union ghw_type *type) } } -static char is_skip_signal( - int *signals_to_keep, - int nb_signals_to_keep, - int signal -) { - int i; - for(i=0; i<nb_signals_to_keep; ++i) { - if(signal==signals_to_keep[i]) { - return 0; - } +static char +is_skip_signal (int *signals_to_keep, int nb_signals_to_keep, int signal) +{ + int i; + for (i = 0; i < nb_signals_to_keep; ++i) + { + if (signal == signals_to_keep[i]) + { + return 0; + } } - return 1; + return 1; } -void ghw_filter_signals( - struct ghw_handler *h, - int *signals_to_keep, - int nb_signals_to_keep -) { - int i; - if(0<nb_signals_to_keep && 0!=signals_to_keep) { - if(0==h->skip_sigs) { - h->skip_sigs = (char*)malloc(sizeof(char)*h->nbr_sigs); - } - for(i=0; i<h->nbr_sigs; ++i) { - h->skip_sigs[i] = is_skip_signal( - signals_to_keep, - nb_signals_to_keep, - i - ); - } - } else { - if(0!=h->skip_sigs) { - free(h->skip_sigs); - h->skip_sigs = 0; - } +void +ghw_filter_signals (struct ghw_handler *h, + int *signals_to_keep, int nb_signals_to_keep) +{ + int i; + if (0 < nb_signals_to_keep && 0 != signals_to_keep) + { + if (0 == h->skip_sigs) + { + h->skip_sigs = (char *) malloc (sizeof (char) * h->nbr_sigs); + } + for (i = 0; i < h->nbr_sigs; ++i) + { + h->skip_sigs[i] = is_skip_signal (signals_to_keep, + nb_signals_to_keep, i); + } + } + else + { + if (0 != h->skip_sigs) + { + free (h->skip_sigs); + h->skip_sigs = 0; + } } } -void ghw_disp_values( - struct ghw_handler *h -) { - int i; - for (i = 0; i < h->nbr_sigs; i++) { - struct ghw_sig *s = &h->sigs[i]; - int skip = (0!=h->skip_sigs && (0!=h->skip_sigs[i])); - if(s->type != NULL && !skip) { - printf ("#%d: ", i); - ghw_disp_value (s->val, s->type); - printf ("\n"); - } +void +ghw_disp_values (struct ghw_handler *h) +{ + int i; + for (i = 0; i < h->nbr_sigs; i++) + { + struct ghw_sig *s = &h->sigs[i]; + int skip = (0 != h->skip_sigs && (0 != h->skip_sigs[i])); + if (s->type != NULL && !skip) + { + printf ("#%d: ", i); + ghw_disp_value (s->val, s->type); + printf ("\n"); + } } } - int ghw_read_directory (struct ghw_handler *h) { |