File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
packages/seacas/libraries/suplib Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ SET(SOURCES
105105 pltone.f
106106 wheneq.f
107107 addlog.c
108+ format_list.c
108109 )
109110
110111TRIBITS_ADD_LIBRARY (
Original file line number Diff line number Diff line change 1+ #include <stdint.h>
2+ #include <stdio.h>
3+ #if defined(_WIN32 ) && defined(_MSC_VER ) && _MSC_VER < 1900
4+ #define PRId64 "I64d"
5+ #else
6+ #include <inttypes.h>
7+ #endif
8+
9+ #if defined(ADDC_ )
10+ void formlist_ (int64_t * ids , int64_t * len )
11+ #else
12+ void formlist (int64_t * ids , int64_t * len )
13+ #endif
14+ {
15+ const char * rng_sep = ".." ;
16+ const char * seq_sep = ", " ;
17+
18+ printf ("\t\t" );
19+ int64_t num = 0 ;
20+ while (num < * len ) {
21+ if (num == 0 ) {
22+ printf ("%" PRId64 "" , ids [num ]);
23+ }
24+ else {
25+ printf ("%s%" PRId64 "" , seq_sep , ids [num ]);
26+ }
27+
28+ int64_t begin = ids [num ]; // first id in range of 1 or more ids
29+ int64_t previous = ids [num ]; // last id in range of 1 or more ids
30+ // Gather a range or single value... (begin .. previous)
31+ while (previous == ids [num ] && ++ num < * len && ids [num ] == previous + 1 ) {
32+ previous ++ ;
33+ }
34+
35+ if (begin != previous ) {
36+ printf ("%s%" PRId64 "" , previous == begin + 1 ? seq_sep : rng_sep , previous );
37+ }
38+ }
39+ printf ("\n\n" );
40+ }
You can’t perform that action at this time.
0 commit comments