57 {
60 const char* kShortPrefix = "-D";
61 const char* kLongPrefix = "--define=";
62 const int kShortPrefixLen = strlen(kShortPrefix);
63 const int kLongPrefixLen = strlen(kLongPrefix);
64 const bool is_short_form =
IsPrefix(kShortPrefix, kShortPrefixLen, arg);
65 const bool is_long_form =
IsPrefix(kLongPrefix, kLongPrefixLen, arg);
66 if (is_short_form) {
67 arg = arg + kShortPrefixLen;
68 } else if (is_long_form) {
69 arg = arg + kLongPrefixLen;
70 } else {
71 return false;
72 }
73 if (*arg == '\0') {
74 return true;
75 }
78 }
79
81 char*
value =
nullptr;
82 const char* equals_pos = strchr(arg, '=');
83 if (equals_pos == nullptr) {
84
85 if (is_short_form) {
87 } else {
89 }
90 return true;
91 }
92 int name_len = equals_pos - arg;
93 if (name_len == 0) {
94 if (is_short_form) {
96 } else {
98 }
99 return true;
100 }
101
102 name =
reinterpret_cast<char*
>(
malloc(name_len + 1));
103 strncpy(
name, arg, name_len);
104 name[name_len] =
'\0';
107 (*environment)
111 if (entry->value != nullptr) {
113 free(entry->value);
114 }
115 entry->value =
value;
116 return true;
117}
static bool SameStringValue(void *key1, void *key2)
static uint32_t StringHash(const char *key)
static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static char * StrDup(const char *s)
static void * GetHashmapKeyFromString(char *key)
static bool IsPrefix(const char *prefix, size_t prefix_len, const char *str)
static dart::SimpleHashMap * environment
void * malloc(size_t size)