PIPS
args.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "genC.h"
#include "misc.h"
+ Include dependency graph for args.c:

Go to the source code of this file.

Functions

void list_to_array (list l, gen_array_t a)
 args.c More...
 
void update_list_from_array (list l, gen_array_t a)
 Just modify the strings in a list from an array of strings. More...
 
void sort_list_of_strings (list l)
 Sort a list of strings. More...
 
string list_to_string (list l)
 Return the malloc()ed version of the concatenation of all the strings in the list. More...
 

Function Documentation

◆ list_to_array()

void list_to_array ( list  l,
gen_array_t  a 
)

args.c

Definition at line 38 of file args.c.

39 {
40  int index = 0;
41  MAP(STRING, s, gen_array_addto(a, index++, s), l);
42  gen_free_list(l);
43 }
void gen_array_addto(gen_array_t a, size_t i, void *what)
Definition: array.c:87
#define STRING(x)
Definition: genC.h:87
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226

References gen_array_addto(), gen_free_list(), MAP, and STRING.

Referenced by prettyprint_dependence_graph(), prettyprint_dependence_graph_view(), sort_list_of_strings(), and xml_Chain_Graph().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ list_to_string()

string list_to_string ( list  l)

Return the malloc()ed version of the concatenation of all the strings in the list.

Definition at line 74 of file args.c.

75 {
76  string result = NULL;
77  if (l == NIL) return strdup("");
78  MAP(STRING,s, {
79  if (result == NULL)
80  result = strdup((const char *)s);
81  else {
82  string new_result = strdup(concatenate(result,s,NULL));
83  free(result);
84  result = new_result;
85  }
86  }, l);
87  return result;
88 }
void free(void *)
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
char * strdup()

References concatenate(), free(), MAP, NIL, strdup(), and STRING.

Referenced by basic_to_string(), c_words_entity(), c_words_simplified_entity(), FindOrCreateCurrentEntity(), flush_statement_comment(), generic_c_words_simplified_entity(), get_symbol_table(), module_loops(), UpdateEntity(), UpdateFunctionEntity(), UpdatePointerEntity(), words_points_to_reference(), and words_type().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sort_list_of_strings()

void sort_list_of_strings ( list  l)

Sort a list of strings.

Definition at line 59 of file args.c.

60 {
61  size_t number_of_strings = gen_length(l);
62  gen_array_t a = gen_array_make(number_of_strings);
63  list_to_array(l, a);
64  pips_assert("same length", number_of_strings == gen_array_nitems(a));
65  gen_array_sort(a);
67  gen_array_free(a);
68 }
void list_to_array(list l, gen_array_t a)
args.c
Definition: args.c:38
void update_list_from_array(list l, gen_array_t a)
Just modify the strings in a list from an array of strings.
Definition: args.c:49
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40
void gen_array_sort(gen_array_t a)
Definition: array.c:164
void gen_array_free(gen_array_t a)
Definition: array.c:70
size_t gen_length(const list l)
Definition: list.c:150
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172

References gen_array_free(), gen_array_make(), gen_array_nitems(), gen_array_sort(), gen_length(), list_to_array(), pips_assert, and update_list_from_array().

+ Here is the call graph for this function:

◆ update_list_from_array()

void update_list_from_array ( list  l,
gen_array_t  a 
)

Just modify the strings in a list from an array of strings.

The array of string must have at least as much as strings as in the list. No free is done.

Definition at line 49 of file args.c.

50 {
51  int index = 0;
52  MAPL(scons, STRING(CAR(scons)) = gen_array_item(a, index++), l);
53 }
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203

References CAR, gen_array_item(), MAPL, and STRING.

Referenced by sort_list_of_strings().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: